title: ASP.NET MVC HttpPost return View() cause error since it can't find cshtml
body: <p>I am writing HttpGet and HttpPost methods in my Controller. I got the HttoPost methods working but I have some questions about the redirect from HttpPost to the HttpGet methods. </p>
  
  <pre><code>[HttpGet]
  public async Task&lt;ActionResult&gt; GetData(MyViewModel model)
  {
      // Get Data 
  
      return View(model); 
  }
  
  
  
  [HttpPost]
  public async Task&lt;ActionResult&gt; UpdateData(MyViewModel model)
  {
              try
              {
                  if (ModelState.IsValid)
                  {
                      // Update updatedModelObject
  
                      //return RedirectToAction("GetData", updatedModelObject);
                      return RedirectToAction("GetData");
                  }
              }
              catch (Exception)
              {
              }
  
              //return RedirectToAction("GetData", "MyController");
  
              //return RedirectToAction("GetData");
  
              return View(model);
  }
  </code></pre>
  
  <p>When I click the submit button on the page, it calls the HttpPost UpdateData method. If the ModelState.IsValid, it update the database and calls the RedirectToAction("GetData"). It does work and calls the HttpGet method to make another call from the database. Here is my problem, if the ModelState.IsValid is false, it will call View(model) which cause the error:</p>
  
  <pre><code>The view 'UpdateData' or its master was not found or no view
  engine supports the searched locations. The following locations were
  searched:
  ~/Views/MyController/UpdateData.cshtml
  ~/Views/MyController/UpdateData.vbhtml
  ~/Views/Shared/UpdateData.cshtml
  ~/Views/Shared/UpdateData.vbhtml
  ~/__MVCSITEMAPPROVIDER/UpdateData.ascx
  </code></pre>
  
  <p>I have been reading many posts where the example HttpGet and HttpPost method are both named Index() so it will not get the same error like I got. I used different HttpGet and HttpPost method names so it was looking for a UpdateData.cshtml. From the posts I read, they say if Model.IsValid is true call the HttpGet with the updated model to pass. If Model.IsValid is false, the posts are saying call View(model) to pass the same model data.</p>
  
  <p>Here are my questions.</p>
  
  <ol>
  <li><p>What should I call instead of View(model) to pass the View with the same model to refresh the View the same model data and avoid the error? As the code as it is, its looking for UpdateData.cshtml </p></li>
  <li><p>If ModelState.IsValid is true, it will update database and call HttpGet to fetch the refreshed data from the database and pass the model to the View in GetData. But if ModelState.IsValid is false, it calls View(model). Does that call HttpGet or just supposed to refresh the View with the old model data?</p></li>
  </ol>
  
  <p>Thanks.</p>