I have a function that returns a generated PDF file but the problem is it shows it in the current browser window… I need for it to open in a new window. I dont see how I can pass it into a view for displaying where I could simply use target: _blank. Any Ideas?
Function showUserPDF(ByVal pdfName As String) As ActionResult
Dim _fileName As String = pdfName
Dim _path As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory) + "\PDF_Files\"
Response.AppendHeader("Content-Disposition", "inline; filename=" + _fileName + ";")
Return File(_path + _fileName, System.Net.Mime.MediaTypeNames.Application.Pdf, _fileName)
End Function
You can’t control the window from server-side code – you need to launch the original request targetting a new window, eg.:
If the request comes from a redirect, then the original request before the redirect would need to be opened in the new window.
You could also use
Content-Disposition: attachmentheader to force the browser to prompt to download.