ASP.Net Control Button PostBack is causing redirection, when I don't want it to at all (print button)
here's how my scenario is created.
I click a button which produces a pdf via iTextSharp.
I then click 'Cancel' on the pop-up dialog.
I navigate to another page via hyperlink.
I then click the 'Back' button on IE8
I then click the button which produces the PDF, th开发者_JAVA技巧en I'm redirected to the page I previously viewed (when I clicked the hyperlink). Which is not intended what so ever.
Here's some code that affects the Response object (code is within print_click event)
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename=ManageWorkforce.pdf");
Response.End();
Anyone have a theory why this is happening?
I have always done this with a generic handler like Greg mentioned. This is also nicer if you want to link to the file from other pages in the future, or save it as a favorite, send it to your friend, etc.
Have you tried using
Response.Clear();
Response.ClearHeaders();
to clear any other content that may still be attached to the response content and headers?
Try to put:
<%@ OutputCache NoStore="true" %>
on the aspx
page.
精彩评论