title: HttpPost and Authorize leads to Error: Server Error in '/' Application. The resource cannot be found
body: <p>In my ASP.Net (.net 4.7 + MVC5) web application I have an action Search() which leads to the an error after authorising the user. The error is as follows:</p>
  
  <blockquote>
    <p>Server Error in '/' Application.</p>
    
    <p>The resource cannot be found.</p>
    
    <p>Description: HTTP 404. The resource you are looking for (or one of its
    dependencies) could have been removed, had its name changed, or is
    temporarily unavailable.  Please review the following URL and make
    sure that it is spelled correctly. </p>
    
    <p>Requested URL: /Search</p>
    
    <p>Version Information: Microsoft .NET Framework Version:4.0.30319;
    ASP.NET Version:4.7.2106.0</p>
  </blockquote>
  
  <p>The action is implemented as follows:</p>
  
  <pre><code>    [Authorize]
      [Route("Search")]
      [HttpPost]
      public ActionResult Search(SearchViewModels passedQuery)
      {
        //Action working code here
        return View("~/Views/Home/Search.cshtml", passedQuery);
      }
  </code></pre>
  
  <p>Form submission code as follows:</p>
  
  <pre><code>@using (Html.BeginForm("Search", "Home"))
  {
      &lt;div class="form-group"&gt;
          @Html.TextBoxFor(m =&gt; m.Content, new { @class = "form-control" })&lt;br /&gt;
          &lt;button type="submit" class="btn btn-danger"&gt;SEARCH&lt;/button&gt;
      &lt;/div&gt;
  }
  </code></pre>
  
  <p>If I take the [HttpPost] out from the action then during debugging mode the application works perfectly even after authorising the user (No error thrown). But without using the [HttpPost] the code does nothing on the production server.</p>
  
  <p>Can someone help with:</p>
  
  <ul>
  <li>Why the error message is shown when [HttpPost] is used with
  [Authroize]? </li>
  <li>When and why to use [HttpPost]? (I have referred to few    posts and
  documents regarding the usage of HttpPost and HttpGet but    still I
  am finding it liitle hard to grasp the concept of their<br>
  appropriate usage<a href="https://stackoverflow.com/questions/5332275/httppost-vs-httpget-attributes-in-mvc-why-use-httppost"> [1]</a>,<a href="https://stackoverflow.com/questions/11767911/mvc-httppost-httpget-for-action"> [2]</a>)</li>
  </ul>
  
  <p>I am very new to ASP.Net and MVC development and any help is really appreciated. Thank you. </p>