HttpResponseWrapper.RedirectToRoute 方法

定義

使用指定的路由參數值、路由名稱或兩者皆使用,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route parameter values, a route name, or both.

多載

RedirectToRoute(Object)

使用指定的路由參數值,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route parameter values.

RedirectToRoute(String)

使用指定的路由名稱,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route name.

RedirectToRoute(RouteValueDictionary)

使用指定的路由參數值,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route parameter values.

RedirectToRoute(String, Object)

使用指定的路由名稱和路由參數值,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route name and route parameter values.

RedirectToRoute(String, RouteValueDictionary)

使用指定的路由名稱和路由參數值,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route name and route parameter values.

RedirectToRoute(Object)

使用指定的路由參數值,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route parameter values.

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

參數

routeValues
Object

路由參數值。The route parameter values.

例外狀況

沒有路由對應到指定的路由參數。No route corresponds to the specified route parameters.

在 HTTP 標頭送出之後嘗試重新導向。Redirection was attempted after the HTTP headers had been sent.

備註

提供此方法的目的是為了方便撰寫程式碼。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.

這個方法會使用函式將傳入的物件轉換 routeValuesSystem.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 會傳回 302 HTTP 狀態碼來執行重新導向。ASP.NET performs the redirection by returning a 302 HTTP status code.

適用於

RedirectToRoute(String)

使用指定的路由名稱,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route name.

public:
 override void RedirectToRoute(System::String ^ routeName);
public override void RedirectToRoute (string routeName);
override this.RedirectToRoute : string -> unit
Public Overrides Sub RedirectToRoute (routeName As String)

參數

routeName
String

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

例外狀況

沒有路由對應至指定的路由名稱。No route corresponds to the specified route name.

在 HTTP 標頭送出之後嘗試重新導向。Redirection was attempted after the HTTP headers had been sent.

備註

提供此方法的目的是為了方便撰寫程式碼。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.

這個方法會使用方法,將傳入的路由名稱轉換 routeName 成 URL RouteCollection.GetVirtualPathThis method converts the route name that is passed in routeName to a URL by using the RouteCollection.GetVirtualPath method.

ASP.NET 會傳回 302 HTTP 狀態碼來執行重新導向。ASP.NET performs the redirection by returning a 302 HTTP status code.

適用於

RedirectToRoute(RouteValueDictionary)

使用指定的路由參數值,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route parameter values.

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

參數

routeValues
RouteValueDictionary

路由參數值。The route parameter values.

例外狀況

沒有路由對應到指定的路由參數。No route corresponds to the specified route parameters.

在 HTTP 標頭送出之後嘗試重新導向。Redirection was attempted after the HTTP headers had been sent.

備註

提供此方法的目的是為了方便撰寫程式碼。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 會傳回 302 HTTP 狀態碼來執行重新導向。ASP.NET performs the redirection by returning a 302 HTTP status code.

適用於

RedirectToRoute(String, Object)

使用指定的路由名稱和路由參數值,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route name and route parameter values.

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

參數

routeName
String

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

routeValues
Object

路由參數值。The route parameter values.

例外狀況

沒有路由對應到指定的路由參數。No route corresponds to the specified route parameters.

在 HTTP 標頭送出之後嘗試重新導向。Redirection was attempted after the HTTP headers had been sent.

備註

提供此方法的目的是為了方便撰寫程式碼。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.

這個方法會使用函式將傳入的物件轉換 routeValuesSystem.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 會傳回 302 HTTP 狀態碼來執行重新導向。ASP.NET performs the redirection by returning a 302 HTTP status code.

適用於

RedirectToRoute(String, RouteValueDictionary)

使用指定的路由名稱和路由參數值,將要求重新導向至新的 URL。Redirects a request to a new URL by using the specified route name and route parameter values.

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

參數

routeName
String

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

routeValues
RouteValueDictionary

路由參數值。The route parameter values.

例外狀況

沒有路由對應到指定的路由參數。No route corresponds to the specified route parameters.

在 HTTP 標頭送出之後嘗試重新導向。Redirection was attempted after the HTTP headers had been sent.

備註

提供此方法的目的是為了方便撰寫程式碼。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。The RouteCollection.GetVirtualPath method is called to determine the URL.

ASP.NET 會傳回 302 HTTP 狀態碼來執行重新導向。ASP.NET performs the redirection by returning a 302 HTTP status code.

適用於