HttpResponse::Redirect Method (String^)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

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

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 Transfer method. The 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.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top