HttpResponse::Redirect Method (String^)
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.
Available since 1.1
