HttpResponse::Redirect Method (String)
Updated: May 2011
Redirects a request to a new URL and specifies the new URL.
Assembly: System.Web (in System.Web.dll)
Parameters
- url
- Type: System::String
The target location.
| Exception | Condition |
|---|---|
| HttpException | 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.
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 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.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note