Using endResponse in Response.Redirect

While executing response.redirect on an ASP.NET page, I got an error:
error: cannot get value
for two variables that are passed (one value is retrieved from the query string, the other from viewstate)



I have never seen this error before, so I did some investigation and found recommendations on using the value "False" for "endResponse"



e.g. Response.Redirect ("mypage.aspx", False)



It worked.



My question is: what are the side effects of using "False" for the value of "endResponse" in response.redirect?

that is, any effects on the server cache? Does this page retain permanent memory for a certain period of time? Will this affect different users viewing the same page? etc.



Thanks!

+4
source share
3 answers

From this other question and this blog post , the recommended template is

Response.Redirect(url, false); Context.ApplicationInstance.CompleteRequest(); 

This avoids the costly ThreadAbortException / Response.End. Some code will be executed after CompleteRequest() , but ASP.Net will close the request as soon as it is convenient.

Edit - I think this answer gives a better overview. Please note: if you use the template above, the code will be executed after the redirect.

+12
source

An MSDN blog post that might answer your question:

The disadvantage of using [Response.Redirect (url, false)] is that the page will continue to be processed on the server and sent to the client. If you redirect to Page_Init (or how) and call Response.Redirect (url, false), the page will be redirected only after the completion of the current page. This means that any server-side processing that you perform on this page will be performed.

+2
source

Response.Redirect (..., true) throws a ThreadAbortException. Depending on your exception handling settings, you may receive your logbook filled with error messages, one for each redirect.

+1
source

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


All Articles