The View accepts some user input and has a "Download" button that lets users download an xml generated based on the entered fields. I also have the [Required] attribute validation in the model that displays the Error message as expected
[Required(ErrorMessage="Provider is Required")]
string provider { get; set; }
When the user fills out the missed mandatory field and hits "Download" the controller returns the xml as a FilePathResult
[AcceptVerbs(HttpVerbs.Post)]
[ValidateInput(false)]
public ActionResult TestXMLCreator(TemplateModel model)
{
.
.
if (ModelState.IsValid)
{
.
.
System.IO.File.WriteAllText(Server.MapPath("~/Generated.xml"), testXml);
return File(Server.MapPath("~/Generated.xml"), "text/plain", testXML.xml");
}
return View(model)
When the ModelState in valid and the File is returned as a result, the view is not refreshed and the old validation errors are still displayed. How can a FileResult be returned and the View refreshed as well?