Pages in ASP.NET still running after page change?

7

The method Response.Redirect has a parameter in one of your overloads named endResponse that when true indicates that the current page should be terminated after the redirect.

Does this mean that when I perform a page redirect (page mute) the previous page is still taking up space somewhere? Would it be a good practice to always use true in this parameter when the current page is no longer used?

    
asked by anonymous 20.12.2013 / 21:21

2 answers

9

This blog post explains in detail the endResponse situation. In short, the behavior of terminating the thread after a redirect was considered a design error, something that is detrimental to the efficiency of ASP but has been maintained for compatibility issues. The recommended method for new code is to always use false , never use true or nothing (ie use the version without the second parameter - which defaults to true ).

If you want to finish rendering after this redirect (that is, there's nothing useful for your code to do next) use Context.ApplicationInstance.CompleteRequest() .

  

Does this mean that when I perform a page redirect (page mute) the previous page is still taking up space somewhere?

The thread used to render the previous page still exists somewhere, and can be reused to serve future requests. If you use endResponse true this thread is destroyed and recreated (costly operation), hence the performance problem.

    
20.12.2013 / 21:31
2

When you pass true to the second parameter it calls the Response.End that causes an exception. And according to the documentation this is more detrimental to performance than pass false (or nothing).

  

This exception has a detrimental effect on Web application performance , which is why passing the endResponse parameter is recommended.

If the End method fails to throw an exception, it will attempt to send the entire buffer to the client in a synchronous manner that is also detrimental to performance.

    
20.12.2013 / 21:29