HttpResponse.RedirectToRoutePermanent HttpResponse.RedirectToRoutePermanent HttpResponse.RedirectToRoutePermanent HttpResponse.RedirectToRoutePermanent Method

定义

使用路由参数值和/或路由名称执行从所请求 URL 到新 URL 的永久重定向。Performs a permanent redirection from a requested URL to a new URL by using route parameter values, a route name, or both.

重载

RedirectToRoutePermanent(String, Object) RedirectToRoutePermanent(String, Object) RedirectToRoutePermanent(String, Object) RedirectToRoutePermanent(String, Object)

使用路由参数值以及与新 URL 对应的路由的名称执行从所请求 URL 到新 URL 的永久重定向。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) RedirectToRoutePermanent(Object) RedirectToRoutePermanent(Object) RedirectToRoutePermanent(Object)

使用路由参数值执行从所请求 URL 到新 URL 的永久重定向。Performs a permanent redirection from a requested URL to a new URL by using route parameter values.

RedirectToRoutePermanent(String) RedirectToRoutePermanent(String) RedirectToRoutePermanent(String) RedirectToRoutePermanent(String)

使用路由名称执行从所请求 URL 到新 URL 的永久重定向。Performs a permanent redirection from a requested URL to a new URL by using a route name.

RedirectToRoutePermanent(RouteValueDictionary) RedirectToRoutePermanent(RouteValueDictionary) RedirectToRoutePermanent(RouteValueDictionary) RedirectToRoutePermanent(RouteValueDictionary)

使用路由参数值执行从所请求 URL 到新 URL 的永久重定向。Performs a permanent redirection from a requested URL to a new URL by using route parameter values.

RedirectToRoutePermanent(String, RouteValueDictionary) RedirectToRoutePermanent(String, RouteValueDictionary) RedirectToRoutePermanent(String, RouteValueDictionary) RedirectToRoutePermanent(String, RouteValueDictionary)

使用路由参数值和路由名称执行从所请求 URL 到新 URL 的永久重定向。Performs a permanent redirection from a requested URL to a new URL by using route parameter values and a route name.

RedirectToRoutePermanent(String, Object) RedirectToRoutePermanent(String, Object) RedirectToRoutePermanent(String, Object) RedirectToRoutePermanent(String, Object)

使用路由参数值以及与新 URL 对应的路由的名称执行从所请求 URL 到新 URL 的永久重定向。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.

public:
 void RedirectToRoutePermanent(System::String ^ routeName, System::Object ^ routeValues);
public void RedirectToRoutePermanent (string routeName, object routeValues);
member this.RedirectToRoutePermanent : string * obj -> unit
Public Sub RedirectToRoutePermanent (routeName As String, routeValues As Object)

参数

routeName
String String String String

路由的名称。The name of the route.

routeValues
Object Object Object Object

路由参数值。The route parameter values.

异常

没有与指定路由参数对应的路由。No route corresponds to the specified route parameters.

在发送 HTTP 标头之后尝试进行重定向。Redirection was attempted after the HTTP headers had been sent.

示例

下面的示例演示如何调用此方法以重定向到名Product为且具有名为productidcategory的参数的路由。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.

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

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用RedirectPermanent方法,并将第二个参数设置为。 falseIt is equivalent to calling the RedirectPermanent method with the second parameter set to false.

此方法使用routeValues System.Web.Routing.RouteValueDictionary 构造函数将传入的对象RouteValueDictionary.RouteValueDictionary(Object)转换为对象。This method converts the object that is passed in routeValues to a System.Web.Routing.RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor. 然后RouteCollection.GetVirtualPath调用方法来确定 URL。The RouteCollection.GetVirtualPath method is then called to determine the URL.

ASP.NET 通过返回 301 HTTP 状态代码来执行重定向。ASP.NET performs the redirection by returning a 301 HTTP status code.

另请参阅

RedirectToRoutePermanent(Object) RedirectToRoutePermanent(Object) RedirectToRoutePermanent(Object) RedirectToRoutePermanent(Object)

使用路由参数值执行从所请求 URL 到新 URL 的永久重定向。Performs a permanent redirection from a requested URL to a new URL by using route parameter values.

public:
 void RedirectToRoutePermanent(System::Object ^ routeValues);
public void RedirectToRoutePermanent (object routeValues);
member this.RedirectToRoutePermanent : obj -> unit
Public Sub RedirectToRoutePermanent (routeValues As Object)

参数

routeValues
Object Object Object Object

路由参数值。The route parameter values.

异常

没有与指定路由参数对应的路由。No route corresponds to the specified route parameters.

在发送 HTTP 标头之后尝试进行重定向。Redirection was attempted after the HTTP headers had been sent.

示例

下面的示例演示如何调用此方法以重定向到具有名为productidcategory的参数的路由。The following example shows how to call this method to redirect to a route that has parameters that are named productid and category.

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

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用RedirectPermanent(String, Boolean)方法,并将第二个参数设置为。 falseIt is equivalent to calling the RedirectPermanent(String, Boolean) method with the second parameter set to false.

此方法使用routeValues System.Web.Routing.RouteValueDictionary 构造函数将传入的对象RouteValueDictionary.RouteValueDictionary(Object)转换为对象。This method converts the object that is passed in routeValues to a System.Web.Routing.RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor. 然后RouteCollection.GetVirtualPath调用方法来确定 URL。The RouteCollection.GetVirtualPath method is then called to determine the URL.

ASP.NET 通过返回 301 HTTP 状态代码来执行重定向。ASP.NET performs the redirection by returning a 301 HTTP status code.

另请参阅

RedirectToRoutePermanent(String) RedirectToRoutePermanent(String) RedirectToRoutePermanent(String) RedirectToRoutePermanent(String)

使用路由名称执行从所请求 URL 到新 URL 的永久重定向。Performs a permanent redirection from a requested URL to a new URL by using a route name.

public:
 void RedirectToRoutePermanent(System::String ^ routeName);
public void RedirectToRoutePermanent (string routeName);
member this.RedirectToRoutePermanent : string -> unit
Public Sub RedirectToRoutePermanent (routeName As String)

参数

routeName
String String String String

路由的名称。The name of the route.

异常

没有与指定路由参数对应的路由。No route corresponds to the specified route parameters.

在发送 HTTP 标头之后尝试进行重定向。Redirection was attempted after the HTTP headers had been sent.

示例

下面的示例演示如何调用此方法以重定向到名Products为的路由。The following example shows how to call this method to redirect to a route that is named Products.

Response.RedirectToRoutePermanent("Products")  
Response.RedirectToRoutePermanent("Products");  

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用RedirectPermanent(String, Boolean)方法,并将第二个参数设置为。 falseIt is equivalent to calling the RedirectPermanent(String, Boolean) method with the second parameter set to false.

此方法routeName RouteCollection.GetVirtualPath使用方法将传入的路由名称转换为 URL。This method converts the route name that is passed in routeName to a URL by using the RouteCollection.GetVirtualPath method.

ASP.NET 通过返回 301 HTTP 状态代码来执行重定向。ASP.NET performs the redirection by returning a 301 HTTP status code.

另请参阅

RedirectToRoutePermanent(RouteValueDictionary) RedirectToRoutePermanent(RouteValueDictionary) RedirectToRoutePermanent(RouteValueDictionary) RedirectToRoutePermanent(RouteValueDictionary)

使用路由参数值执行从所请求 URL 到新 URL 的永久重定向。Performs a permanent redirection from a requested URL to a new URL by using route parameter values.

public:
 void RedirectToRoutePermanent(System::Web::Routing::RouteValueDictionary ^ routeValues);
public void RedirectToRoutePermanent (System.Web.Routing.RouteValueDictionary routeValues);
member this.RedirectToRoutePermanent : System.Web.Routing.RouteValueDictionary -> unit
Public Sub RedirectToRoutePermanent (routeValues As RouteValueDictionary)

参数

routeValues
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

路由参数值。The route parameter values.

异常

没有与指定路由参数对应的路由。No route corresponds to the specified route parameters.

在发送 HTTP 标头之后尝试进行重定向。Redirection was attempted after the HTTP headers had been sent.

示例

下面的示例演示如何调用此方法以重定向到具有名为productidcategory的参数的路由。The following example shows how to call this method to redirect to a route that has parameters that are named productid and category.

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

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用Redirect(String, Boolean)方法,并将第二个参数设置为。 falseIt is equivalent to calling the Redirect(String, Boolean) method with the second parameter set to false.

此方法调用RouteCollection.GetVirtualPath方法来确定 URL。This method calls the RouteCollection.GetVirtualPath method to determine the URL.

ASP.NET 通过返回 301 HTTP 状态代码来执行重定向。ASP.NET performs the redirection by returning a 301 HTTP status code.

另请参阅

RedirectToRoutePermanent(String, RouteValueDictionary) RedirectToRoutePermanent(String, RouteValueDictionary) RedirectToRoutePermanent(String, RouteValueDictionary) RedirectToRoutePermanent(String, RouteValueDictionary)

使用路由参数值和路由名称执行从所请求 URL 到新 URL 的永久重定向。Performs a permanent redirection from a requested URL to a new URL by using route parameter values and a route name.

public:
 void RedirectToRoutePermanent(System::String ^ routeName, System::Web::Routing::RouteValueDictionary ^ routeValues);
public void RedirectToRoutePermanent (string routeName, System.Web.Routing.RouteValueDictionary routeValues);
member this.RedirectToRoutePermanent : string * System.Web.Routing.RouteValueDictionary -> unit
Public Sub RedirectToRoutePermanent (routeName As String, routeValues As RouteValueDictionary)

参数

routeName
String String String String

路由的名称。The name of the route.

routeValues
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

路由参数值。The route parameter values.

异常

没有与指定路由参数对应的路由。No route corresponds to the specified route parameters.

在发送 HTTP 标头之后尝试进行重定向。Redirection was attempted after the HTTP headers had been sent.

示例

下面的示例演示如何调用此方法以重定向到名Product为且具有名为productidcategory的参数的路由。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.

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

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用Redirect(String, Boolean)方法,并将第二个参数设置为。 falseIt is equivalent to calling the Redirect(String, Boolean) method with the second parameter set to false.

此方法调用RouteCollection.GetVirtualPath方法来确定 URL。This method calls the RouteCollection.GetVirtualPath method to determine the URL.

ASP.NET 通过返回 301 HTTP 状态代码来执行重定向。ASP.NET performs the redirection by returning a 301 HTTP status code.

另请参阅

适用于