ASP.Net PostBack control button causes redirection when I don't want it at all (print button)

here how my script is created.

I press a button that creates a pdf file via iTextSharp.

Then click Cancel in the pop-up dialog box.

I go to another page through a hyperlink.

Then I press the back button on IE8

Then I click on the button that creates the PDF, after which I am redirected to the previously viewed page (when I clicked the hyperlink). Which is not meant for anything else.

Here is some code that affects the Response object (the code is in the print_click event)

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename=ManageWorkforce.pdf");
Response.End();

Does anyone have a theory why this is happening?

+3
3

, . , , ..

+1

 Response.Clear();
 Response.ClearHeaders();

, ?

0

Try to put:

<%@ OutputCache NoStore="true" %>

on the page aspx.

0
source

Source: https://habr.com/ru/post/1773939/


All Articles