title: Using IsPost in asp.net core razor page to display text after form submission
body: <p>I'm trying to use the IsPost method in my asp.net core web page, but it says it does not exist in the current context. Since I'm not using MVC, (other than the fact that I have a models folder), is it possible for me to use IsPost in my razor page? Basically I am trying to display confirmation text on the same page after the user hits the submit button, so if anyone has a better way of doing this, please suggest so. Thanks</p>
  
  <p><strong>FreeConsultation.cshtml</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@page
  @model GuptaAccounting.Pages.FreeConsultationModel
  @{
      ViewData["Title"] = "FreeConsultation";
  }
  
  &lt;head&gt;
      &lt;script src="~/js/site.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;div class="container" style="padding:30px;"&gt;
      &lt;br /&gt;
      &lt;h1 class="text-info"&gt;Get a FREE Consultation&lt;/h1&gt;
      &lt;br /&gt;
      @if (IsPost)
      {
          &lt;p&gt;Consultation requested. I will get back to you as soon as possible&lt;/p&gt;
      }
      else
      {
          &lt;form method="post"&gt;
              &lt;div class="text-danger" asp-validation-summary="ModelOnly"&gt;&lt;/div&gt;
              
              &lt;!-- More of the form here --&gt;
              
                          &lt;div class="form-group row"&gt;
                  &lt;div class="col-3 offset-3"&gt;
                      &lt;input type="submit" value="Submit" onclick="return Validate()"  class="btn btn-primary form-control" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>FreeConsultation.cshtml.cs</strong></p>
  
  <pre><code>public class FreeConsultationModel : PageModel
  {
      private readonly ApplicationDbContext _db;
  
      public FreeConsultationModel(ApplicationDbContext db)
      {
          _db = db;
      }
  
      [BindProperty]
      public Client Client { get; set; }
  
      public void OnGet()
      {
  
      }
  
      public async Task&lt;IActionResult&gt; OnPost()
      {
          if (ModelState.IsValid)
          {
              Client.IsConsultationClient = true;
              await _db.Client.AddAsync(Client);
              await _db.SaveChangesAsync();
  
              return RedirectToPage("Index");
          }
          else
          {
              return Page();
          }
      }
  }
  </code></pre>