Redirect Method (String)
Collapse the table of content
Expand the table of content

HttpResponse.Redirect Method (String)


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

Namespace:   System.Web
Assembly:  System.Web (in System.Web.dll)

public void Redirect(
	string url


Type: System.String

The target location.

Exception Condition

A redirection is attempted after the HTTP headers have been sent.

Calling Redirect is equivalent to calling Redirect with the second parameter set to true.

Redirect calls End which throws a 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, Boolean) overload and pass false for the endResponse parameter, and then call the CompleteRequest method. For more information, see the End method.


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 ResolveUrl "~/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 M:System.Web.HttpServerUtility.Transfer method. The M:System.Web.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.

The following example forces an unconditional redirection to another Web site.


.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft