MetaGuru
MetaGuru

Reputation: 43853

Why does Response.Redirect close my browser window instead of redirecting?

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...)

Upvotes: 0

Views: 2720

Answers (5)

matt
matt

Reputation:

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 https://stackoverflow.com/questions/400010/ie-closing-just-opened-popup-window theres some good stuff in there that may help.

Upvotes: 1

Kibbee
Kibbee

Reputation: 66132

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.

Upvotes: 0

Eppz
Eppz

Reputation: 3206

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

If you do

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

What happens?

Upvotes: 1

splattne
splattne

Reputation: 104040

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.

Upvotes: 1

Sean Bright
Sean Bright

Reputation: 120654

Maybe the Adobe Reader plugin is crashing the browser?

Upvotes: 3

Related Questions