HttpResponse.RedirectToRoute Método
Definição
Redireciona uma solicitação para uma nova URL usando valores de parâmetro de rota, um nome de rota ou ambos.Redirects a request to a new URL by using route parameter values, a route name, or both.
Sobrecargas
| RedirectToRoute(Object) |
Redireciona uma solicitação para uma nova URL usando valores de parâmetro de rota.Redirects a request to a new URL by using route parameter values. |
| RedirectToRoute(String) |
Redireciona uma solicitação para uma nova URL usando um nome de rota.Redirects a request to a new URL by using a route name. |
| RedirectToRoute(RouteValueDictionary) |
Redireciona uma solicitação para uma nova URL usando valores de parâmetro de rota.Redirects a request to a new URL by using route parameter values. |
| RedirectToRoute(String, Object) |
Redireciona uma solicitação para uma nova URL usando valores de parâmetro de rota e um nome de rota.Redirects a request to a new URL by using route parameter values and a route name. |
| RedirectToRoute(String, RouteValueDictionary) |
Redireciona uma solicitação para uma nova URL usando valores de parâmetro de rota e um nome de rota.Redirects a request to a new URL by using route parameter values and a route name. |
RedirectToRoute(Object)
Redireciona uma solicitação para uma nova URL usando valores de parâmetro de rota.Redirects a request to a new URL by using route parameter values.
public:
void RedirectToRoute(System::Object ^ routeValues);
public void RedirectToRoute (object routeValues);
member this.RedirectToRoute : obj -> unit
Public Sub RedirectToRoute (routeValues As Object)
Parâmetros
- routeValues
- Object
Os valores de parâmetro de rota.The route parameter values.
Exceções
Nenhuma rota corresponde aos parâmetros de rotas especificados.No route corresponds to the specified route parameters.
Houve uma tentativa de redirecionamento após o envio dos cabeçalhos HTTP.Redirection was attempted after the HTTP headers had been sent.
Exemplos
O exemplo a seguir mostra como chamar esse método para redirecionar para uma rota que tem parâmetros nomeados productid e category .The following example shows how to call this method to redirect to a route that has parameters that are named productid and category.
Response.RedirectToRoute(
New With {.productid = "1", .category = "widgets"})
Response.RedirectToRoute(
new { productid = "1", category = "widgets" });
Comentários
Esse método é fornecido para a conveniência da codificação.This method is provided for coding convenience. É equivalente a chamar o Redirect(String, Boolean) método com o segundo parâmetro definido como false .It is equivalent to calling the Redirect(String, Boolean) method with the second parameter set to false.
Esse método converte o objeto que é passado routeValues para um System.Web.Routing.RouteValueDictionary objeto usando o RouteValueDictionary.RouteValueDictionary(Object) Construtor.This method converts the object that is passed in routeValues to a System.Web.Routing.RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor. O RouteCollection.GetVirtualPath método é chamado para determinar a URL.The RouteCollection.GetVirtualPath method is then called to determine the URL.
ASP.NET executa o redirecionamento retornando um código de status HTTP 302.ASP.NET performs the redirection by returning a 302 HTTP status code.
Aplica-se a
RedirectToRoute(String)
Redireciona uma solicitação para uma nova URL usando um nome de rota.Redirects a request to a new URL by using a route name.
public:
void RedirectToRoute(System::String ^ routeName);
public void RedirectToRoute (string routeName);
member this.RedirectToRoute : string -> unit
Public Sub RedirectToRoute (routeName As String)
Parâmetros
- routeName
- String
O nome da rota.The name of the route.
Exceções
Nenhuma rota corresponde aos parâmetros de rotas especificados.No route corresponds to the specified route parameters.
Houve uma tentativa de redirecionamento após o envio dos cabeçalhos HTTP.Redirection was attempted after the HTTP headers had been sent.
Exemplos
O exemplo a seguir mostra como chamar esse método para redirecionar para uma rota denominada Products .The following example shows how to call this method to redirect to a route that is named Products.
Response.RedirectToRoute("Products")
Response.RedirectToRoute("Products");
Comentários
Esse método é fornecido para a conveniência da codificação.This method is provided for coding convenience. É equivalente a chamar o Redirect(String, Boolean) método com o segundo parâmetro definido como false .It is equivalent to calling the Redirect(String, Boolean) method with the second parameter set to false.
Esse método converte o nome de rota que é passado routeName para uma URL usando o RouteCollection.GetVirtualPath método.This method converts the route name that is passed in routeName to a URL by using the RouteCollection.GetVirtualPath method.
ASP.NET executa o redirecionamento retornando um código de status HTTP 302.ASP.NET performs the redirection by returning a 302 HTTP status code.
Aplica-se a
RedirectToRoute(RouteValueDictionary)
Redireciona uma solicitação para uma nova URL usando valores de parâmetro de rota.Redirects a request to a new URL by using route parameter values.
public:
void RedirectToRoute(System::Web::Routing::RouteValueDictionary ^ routeValues);
public void RedirectToRoute (System.Web.Routing.RouteValueDictionary routeValues);
member this.RedirectToRoute : System.Web.Routing.RouteValueDictionary -> unit
Public Sub RedirectToRoute (routeValues As RouteValueDictionary)
Parâmetros
- routeValues
- RouteValueDictionary
Os valores de parâmetro de rota.The route parameter values.
Exceções
Nenhuma rota corresponde aos parâmetros de rotas especificados.No route corresponds to the specified route parameters.
Houve uma tentativa de redirecionamento após o envio dos cabeçalhos HTTP.Redirection was attempted after the HTTP headers had been sent.
Exemplos
O exemplo a seguir mostra como chamar esse método para redirecionar para uma rota que tem parâmetros nomeados productid e category .The following example shows how to call this method to redirect to a route that has parameters that are named productid and category.
Response.RedirectToRoute(
new RouteValueDictionary {productId="1", category="widgets"})
Response.RedirectToRoute(
(new RouteValueDictionary {productId="1", category="widgets"});
Comentários
Esse método é fornecido para a conveniência da codificação.This method is provided for coding convenience. É equivalente a chamar o Redirect(String, Boolean) método com o segundo parâmetro definido como false .It is equivalent to calling the Redirect(String, Boolean) method with the second parameter set to false.
Esse método chama o RouteCollection.GetVirtualPath método para determinar a URL.This method calls the RouteCollection.GetVirtualPath method to determine the URL.
ASP.NET executa o redirecionamento retornando um código de status HTTP 302.ASP.NET performs the redirection by returning a 302 HTTP status code.
Aplica-se a
RedirectToRoute(String, Object)
Redireciona uma solicitação para uma nova URL usando valores de parâmetro de rota e um nome de rota.Redirects a request to a new URL by using route parameter values and a route name.
public:
void RedirectToRoute(System::String ^ routeName, System::Object ^ routeValues);
public void RedirectToRoute (string routeName, object routeValues);
member this.RedirectToRoute : string * obj -> unit
Public Sub RedirectToRoute (routeName As String, routeValues As Object)
Parâmetros
- routeName
- String
O nome da rota.The name of the route.
- routeValues
- Object
Os valores de parâmetro de rota.The route parameter values.
Exceções
Nenhuma rota corresponde aos parâmetros de rotas especificados.No route corresponds to the specified route parameters.
Houve uma tentativa de redirecionamento após o envio dos cabeçalhos HTTP.Redirection was attempted after the HTTP headers had been sent.
Exemplos
O exemplo a seguir mostra como chamar esse método para redirecionar para uma rota denominada Product e que tem parâmetros nomeados productid e category .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.RedirectToRoute("Product",
New With {.productid = "1", .category = "widgets"})
Response.RedirectToRoute("Product",
new { productid = "1", category = "widgets" });
Comentários
Esse método é fornecido para a conveniência da codificação.This method is provided for coding convenience. É equivalente a chamar o Redirect(String, Boolean) método com o segundo parâmetro definido como false .It is equivalent to calling the Redirect(String, Boolean) method with the second parameter set to false.
Esse método converte o objeto que é passado routeValues para um System.Web.Routing.RouteValueDictionary objeto usando o RouteValueDictionary.RouteValueDictionary(Object) Construtor.This method converts the object that is passed in routeValues to a System.Web.Routing.RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor. O RouteCollection.GetVirtualPath método é chamado para determinar a URL.The RouteCollection.GetVirtualPath method is then called to determine the URL.
ASP.NET executa o redirecionamento retornando um código de status HTTP 302.ASP.NET performs the redirection by returning a 302 HTTP status code.
Aplica-se a
RedirectToRoute(String, RouteValueDictionary)
Redireciona uma solicitação para uma nova URL usando valores de parâmetro de rota e um nome de rota.Redirects a request to a new URL by using route parameter values and a route name.
public:
void RedirectToRoute(System::String ^ routeName, System::Web::Routing::RouteValueDictionary ^ routeValues);
public void RedirectToRoute (string routeName, System.Web.Routing.RouteValueDictionary routeValues);
member this.RedirectToRoute : string * System.Web.Routing.RouteValueDictionary -> unit
Public Sub RedirectToRoute (routeName As String, routeValues As RouteValueDictionary)
Parâmetros
- routeName
- String
O nome da rota.The name of the route.
- routeValues
- RouteValueDictionary
Os valores de parâmetro de rota.The route parameter values.
Exceções
Nenhuma rota corresponde aos parâmetros de rotas especificados.No route corresponds to the specified route parameters.
Houve uma tentativa de redirecionamento após o envio dos cabeçalhos HTTP.Redirection was attempted after the HTTP headers had been sent.
Exemplos
O exemplo a seguir mostra como chamar esse método para redirecionar para uma rota denominada Product e que tem parâmetros nomeados productid e category .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.RedirectToRoute("Product",
new RouteValueDictionary {productId="1", category="widgets"})
Response.RedirectToRoute("Product",
(new RouteValueDictionary {productId="1", category="widgets"});
Comentários
Esse método é fornecido para a conveniência da codificação.This method is provided for coding convenience. É equivalente a chamar o Redirect(String, Boolean) método com o segundo parâmetro definido como false .It is equivalent to calling the Redirect(String, Boolean) method with the second parameter set to false.
O RouteCollection.GetVirtualPath método é chamado para determinar a URL.The RouteCollection.GetVirtualPath method is called to determine the URL.
ASP.NET executa o redirecionamento retornando um código de status HTTP 302.ASP.NET performs the redirection by returning a 302 HTTP status code.