title: ASP.NET MVC how to reset form when action returns a FileResult?
body: <p>I have an ASP.NET MVC form that when submitted can return either an <code>ActionResult</code> if there was an error with the data, or if everything is fine it redirects to a different action that returns a <code>FileResult</code>.</p>
  
  <p>I've created a bit of a sample to provide an idea of what I am doing. This is the html:</p>
  
  <pre><code>&lt;%
  using (Html.BeginForm())
  %&gt;
      &lt;%= Html.ValidationSummary(
          "Edit was unsuccessful. Please correct the errors and try again.") %&gt;
      &lt;%= Html.TextBox("YourName", Model.YourName)%&gt;
      &lt;%= Html.ValidationMessage("YourName", "*") %&gt;
      &lt;input type="submit" /&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>and the controller code is:</p>
  
  <pre><code>[AcceptVerbs(HttpVerbs.Post)]
  public ActionResult MyPostSample(string YourName)
  {
      if (string.IsNullOrEmpty(YourName))
      {
           ModelState.AddModelError("YourName", "You must specify a name");
      }
  
      if (ModelState.IsValid)
      {
           // get the file
           RedirectToAction("GetFile");
      }
      else
      {
           // return this actions View with errors
           return View();
      }
  }
  
  public FileResult GetFile(string YourName)
  {
      // return file here
  }
  </code></pre>
  
  <p>The reason for the <code>ActionResult</code> is to populate ModelState errors so the user can correct and try again.</p>
  
  <p>This all works fine, except I would like the form to be reset or cleared if a file is returned by the server. Currently the user gets a File dialog, but the form retains the submitted values. What can I do to reset the form after a successful submit?</p>