System.Web.HttpResponse.Redirect Method

Redirects a request to a new URL and specifies the new URL.

Syntax

public void Redirect (string url)

Parameters

url
The target location.

Remarks

Calling HttpResponse.Redirect(string) is equivalent to calling HttpResponse.Redirect(string, bool) with the second parameter set to true.

HttpResponse.Redirect(string) calls HttpResponse.End which throws a System.Threading.ThreadAbortException exception upon completion. This exception has a detrimental effect on Web application performance. Therefore, we recommend that instead of this overload you use the HttpResponse.Redirect(string, bool) overload and pass false for the endResponse parameter, and then call the HttpApplication.CompleteRequest method. For more information, see the HttpResponse.End method.

Note:

For mobile pages only, if your application relies on cookieless sessions, or might receive requests from mobile devices that require cookieless sessions, using a tilde (~) in a path can result in creating a new session and potentially losing session data. To set a property on a mobile control with a path such as "~/path", resolve the path using System.Web.UI.MobileControls.MobileControl.ResolveUrl(string) "~/path" before assigning it to the property.

ASP.NET performs the redirection by returning a 302 HTTP status code. An alternative way to transfer control to another page is the HttpServerUtility.Transfer method. The HttpServerUtility.Transfer method is typically more efficient because it does not cause a round trip to the client. For more information, see How to: Redirect Users to Another Page.

Requirements

Namespace: System.Web
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0