Monday, June 13, 2011

What is recommended practice for Response.Redirect ?

Use Response.Redirect ( URL , false);

The second parameter false is important, it avoids calling the End method  of calling page.


Response.Redirect uses HTTP 302 status code (Moved Temporarily) in the background.




http://msdn.microsoft.com/en-us/library/a8wa7sdt.aspx

When you use this method in a page handler to terminate a request for one page and start a new request for another page, set endResponse to false and then call the CompleteRequest() method. If you specify true for the endResponse parameter, this method calls the End method for the original request, which throws a ThreadAbortException exception when it completes. This exception has a detrimental effect on Web application performance, which is why passing false for the endResponse parameter is recommended. For more information, see the End method.

ASP.NET performs the redirection by returning a 302 HTTP status code.



http://support.microsoft.com/kb/312629/EN-US/

PRB: ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer

No comments:

Post a Comment

 using Microsoft.AspNetCore.Mvc; using System.Xml.Linq; using System.Xml.XPath; //<table class="common-table medium js-table js-stre...