Open a new tab in a browser with the response to an ASP request

Posted by user89691 on Stack Overflow See other posts from Stack Overflow or by user89691
Published on 2010-04-27T00:27:10Z Indexed on 2010/04/27 0:33 UTC
Read the original article Hit count: 340

Filed under:
|
|
|
|

It's a bit complicated this one... Lets say I have a listing of PDF files displayed in the user's browser. Each filename is a link pointing not to the file, but to an ASP page, say

<--a href="viewfile.asp?file=somefile.pdf">somefile.pdf</a>  

I want viewfile.asp to fetch the file (I've done that bit OK) but I then want the file to be loaded by the browser as if the user had opened the PDF file directly. And I want it to open in a new tab or browser window.

here's (simplified) viewfile.asp:

<%
var FileID   = Request.querystring ("file") ;
var ResponseBody = MyGETRequest (SomeURL + FileID) ;

if (MyHTTPResult == 200)
    { 
    if (ExtractFileExt (FileID).toLowerCase = "pdf")
        {
        ??????  // return file contents in new browser tab
        }        
....
%>

© Stack Overflow or respective owner

Related posts about asp

Related posts about http