views:

1077

answers:

5

For whatever reason when I use Response.Redirect the window just closes out instead of navigating to the given URL, here is the code.

    if (mode == "print")
    {
        error_code.Text = "";
        //thumb.Src = file_loc + "source/" + "certificate_thumbnail.jpeg";
        link.HRef = "Certificates/" + u_name + ".pdf";
        link.Visible = true;
        Response.Redirect("http://xx.xxxxxxxxxxxxx.xx.gov/cert/Certificates/" + u_name + ".pdf");


    }

(I removed the url for security purposes given who my client is...)

+3  A: 

Maybe the Adobe Reader plugin is crashing the browser?

Sean Bright
+1  A: 

Use Firebug in Firefox or a http debugging proxy like Fiddler for Internet Explorer to see exactly what the response of the server contains. Maybe the response isn't a PDF, but text/html which contains a Javascript window.close().

My guess is, that the code you posted isn't being executed for some reason and something else is happening.

splattne
+1  A: 

What ever you have as your default PDF reader is likely causing this.

If you do

Response.Redirect("http://www.google.com");

What happens?

Eppz
I tried that and it redirects to google fine. It must be Adobe Reader because after I enable 'open PDF in browser' any pdf I try to open anywhere just throws an empty pop-up with the '?' system icon. When I turn this off PDFs just download and open in adobe reader (but just closes window here still)
shogun
the '?' thing has only been happening since Windows 7 so could be a bug for that, I will try in XP, thanks.
shogun
OK I tried in XP and the thing still closes the browser instead of at least asking me where to download the file...
shogun
A: 

Try redirecting to a PDF that you know is valid. By searching google for PDF, I was able to find this PDF (http://www.utoronto.ca/cip/sa_ArtGt.pdf). So, if you redirect to that link does it still close the browser window? If it doesn't it's most likely related to your specific PDF file. If there's something wrong with your PDF File, try to regenerate it, if at all possible.

Kibbee
+1  A: 

The problem is due to you opening an aspx page which contains the redirect to .pdf. As the aspx is pre-compiled when its opened by IE it EXPECTS text/html to come back - however as you've redirected its actually receiving application/pdf so IE craps itself and closes. Try it in firefox - works fine I bet.

I actually have the exact same problem at the moment and have yet to get a workaround. However check out this link http://stackoverflow.com/questions/400010/ie-closing-just-opened-popup-window theres some good stuff in there that may help.