Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC3 return a File always in a new tab without replace the old one

I have a form with target="_blank" that posts, process and return a PDF File in a new tab, the problem is:

When I do first time, it's all OK, but when i do again, instead of opening a new tab, it replaces the old one with the new content!

And if i'm using Internet Explorer, it posts my parameters null, in this case I need to close the new tab, and do it again

Controller:

public ActionResult SubmitReport(string parameter)
{
   // all the code
   return File(stream, "application/pdf");
}

View:

@using (Html.BeginForm("SubmitReport", "ResumoPagamentos", FormMethod.Post, new { area = "CI3S", @target = "_Blank" }))
{
  // etc.. etc...
}
like image 311
Walter Avatar asked Jan 28 '26 19:01

Walter


1 Answers

HTML target values are case-sensitive.

_Blank (capital B) is not the special _blank value (which always opens a new tab), but a tab named _Blank, which will be reused if it exists.

like image 126
SLaks Avatar answered Jan 30 '26 14:01

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!