title: How to determine if the view is for GET or POST in ASP.NET MVC?
body: <p>MVC use action attributes to map the same view for http get or post:</p>
  
  <pre><code> [HttpGet] 
   public ActionResult Index()
   {
      ViewBag.Message = "Message";
      return View();
   }
  
   [HttpPost]
   public ActionResult Index(decimal a, decimal b, string operation)
   {
       ViewBag.Message = "Calculation Result:";
       ViewBag.Result = Calculation.Execute(a, b, operation);
       return View();
   }
  </code></pre>
  
  <p>In the MVC view, how can I determine if the view is for http get or http post?</p>
  
  <hr>
  
  <p>in Views it is <code>IsPost</code></p>
  
  <pre><code>@{
       var Message="";
       if(IsPost)
        {
              Message ="This is from the postback";
        }
         else
      {
              Message="This is without postback";
      }
  }
  </code></pre>
  
  <p>PS: For dot net core it is:</p>
  
  <pre><code>Context.Request.Method == "POST"
  </code></pre>