Here I have a filtering report page, where I can filter some information for a report (RDLC, returning a PDF or Image file). Today, this page return files always on a fresh tab, because I'm using this:
@using (Html.BeginForm("Report", "ReportController", FormMethod.Post, new { target = "_blank" }))
and my ReportController returns a FileContentResult, as shown below:
return File(renderedBytes, mimeType, fileName + "." + fileNameExtension);
However, this page have some server-side validation, and the postback occurs always on the freshly created tab, not on the original one where the submit button was clicked. Is there a way of returning a new page (target = "_blank", with generated PDF or Image) only if ModelState has no errors? I want to stick on the report filtering page if there are errors.
Thank you in advance.