Export (0) Print
Expand All

HttpResponse.Redirect Method (String)

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

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

public void Redirect (
	string url
)
public void Redirect (
	String url
)
public function Redirect (
	url : String
)
Not applicable.

Parameters

url

The target location.

Exception typeCondition

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 raises a ThreadAbortException exception upon completion.

NoteNote:

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 inadvertently 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.

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

Response.Redirect("http://www.microsoft.com/gohere/look.htm");
   

get_Response().Redirect("http://www.microsoft.com/gohere/look.htm");

Response.Redirect("http://www.microsoft.com/gohere/look.htm")
   

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft