HttpResponse.RedirectToRoutePermanent Method

Definition

Performs a permanent redirection from a requested URL to a new URL by using route parameter values, a route name, or both.

Overloads

RedirectToRoutePermanent(String, Object)

Performs a permanent redirection from a requested URL to a new URL by using the route parameter values and the name of the route that correspond to the new URL.

RedirectToRoutePermanent(Object)

Performs a permanent redirection from a requested URL to a new URL by using route parameter values.

RedirectToRoutePermanent(String)

Performs a permanent redirection from a requested URL to a new URL by using a route name.

RedirectToRoutePermanent(RouteValueDictionary)

Performs a permanent redirection from a requested URL to a new URL by using route parameter values.

RedirectToRoutePermanent(String, RouteValueDictionary)

Performs a permanent redirection from a requested URL to a new URL by using route parameter values and a route name.

RedirectToRoutePermanent(String, Object)

Performs a permanent redirection from a requested URL to a new URL by using the route parameter values and the name of the route that correspond to the new URL.

C#
public void RedirectToRoutePermanent(string routeName, object routeValues);

Parameters

routeName
String

The name of the route.

routeValues
Object

The route parameter values.

Exceptions

No route corresponds to the specified route parameters.

Redirection was attempted after the HTTP headers had been sent.

Examples

The following example shows how to call this method to redirect to a route that is named Product and that has parameters that are named productid and category.

C#
Response.RedirectToRoutePermanent("Product",
  new { productid = "1", category = "widgets" });

Remarks

This method is provided for coding convenience. It is equivalent to calling the RedirectPermanent method with the second parameter set to false.

This method converts the object that is passed in routeValues to a System.Web.Routing.RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor. The RouteCollection.GetVirtualPath method is then called to determine the URL.

ASP.NET performs the redirection by returning a 301 HTTP status code.

See also

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

RedirectToRoutePermanent(Object)

Performs a permanent redirection from a requested URL to a new URL by using route parameter values.

C#
public void RedirectToRoutePermanent(object routeValues);

Parameters

routeValues
Object

The route parameter values.

Exceptions

No route corresponds to the specified route parameters.

Redirection was attempted after the HTTP headers had been sent.

Examples

The following example shows how to call this method to redirect to a route that has parameters that are named productid and category.

C#
Response.RedirectToRoutePermanent(
  new { productid = "1", category = "widgets" });

Remarks

This method is provided for coding convenience. It is equivalent to calling the RedirectPermanent(String, Boolean) method with the second parameter set to false.

This method converts the object that is passed in routeValues to a System.Web.Routing.RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor. The RouteCollection.GetVirtualPath method is then called to determine the URL.

ASP.NET performs the redirection by returning a 301 HTTP status code.

See also

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

RedirectToRoutePermanent(String)

Performs a permanent redirection from a requested URL to a new URL by using a route name.

C#
public void RedirectToRoutePermanent(string routeName);

Parameters

routeName
String

The name of the route.

Exceptions

No route corresponds to the specified route parameters.

Redirection was attempted after the HTTP headers had been sent.

Examples

The following example shows how to call this method to redirect to a route that is named Products.

C#
Response.RedirectToRoutePermanent("Products");

Remarks

This method is provided for coding convenience. It is equivalent to calling the RedirectPermanent(String, Boolean) method with the second parameter set to false.

This method converts the route name that is passed in routeName to a URL by using the RouteCollection.GetVirtualPath method.

ASP.NET performs the redirection by returning a 301 HTTP status code.

See also

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

RedirectToRoutePermanent(RouteValueDictionary)

Performs a permanent redirection from a requested URL to a new URL by using route parameter values.

C#
public void RedirectToRoutePermanent(System.Web.Routing.RouteValueDictionary routeValues);

Parameters

routeValues
RouteValueDictionary

The route parameter values.

Exceptions

No route corresponds to the specified route parameters.

Redirection was attempted after the HTTP headers had been sent.

Examples

The following example shows how to call this method to redirect to a route that has parameters that are named productid and category.

C#
Response.RedirectToRoutePermanent(
  new RouteValueDictionary {productId="1", category="widgets"});

Remarks

This method is provided for coding convenience. It is equivalent to calling the Redirect(String, Boolean) method with the second parameter set to false.

This method calls the RouteCollection.GetVirtualPath method to determine the URL.

ASP.NET performs the redirection by returning a 301 HTTP status code.

See also

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

RedirectToRoutePermanent(String, RouteValueDictionary)

Performs a permanent redirection from a requested URL to a new URL by using route parameter values and a route name.

C#
public void RedirectToRoutePermanent(string routeName, System.Web.Routing.RouteValueDictionary routeValues);

Parameters

routeName
String

The name of the route.

routeValues
RouteValueDictionary

The route parameter values.

Exceptions

No route corresponds to the specified route parameters.

Redirection was attempted after the HTTP headers had been sent.

Examples

The following example shows how to call this method to redirect to a route that is named Product and that has parameters that are named productid and category.

C#
Response.RedirectToRoutePermanent("Product",
  new RouteValueDictionary {productId="1", category="widgets"});

Remarks

This method is provided for coding convenience. It is equivalent to calling the Redirect(String, Boolean) method with the second parameter set to false.

This method calls the RouteCollection.GetVirtualPath method to determine the URL.

ASP.NET performs the redirection by returning a 301 HTTP status code.

See also

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1