Control.GetRouteUrl Control.GetRouteUrl Control.GetRouteUrl Control.GetRouteUrl Method

定义

获取与一组路由参数对应的 URL,以及(可选)与路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters, and optionally to a route name.

重载

GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object)

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary)

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用RouteCollection.GetVirtualPath方法。It is equivalent to calling the RouteCollection.GetVirtualPath method.

GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

public:
 System::String ^ GetRouteUrl(System::Object ^ routeParameters);
public string GetRouteUrl (object routeParameters);
member this.GetRouteUrl : obj -> string
Public Function GetRouteUrl (routeParameters As Object) As String

参数

routeParameters
Object Object Object Object

路由参数。The route parameters.

返回

与指定路由参数对应的 URL。The URL that corresponds to the specified route parameters.

示例

下面的示例演示如何调用Control.GetRouteUrl方法来获取具有名为productidcategory的参数的路由的 URL。The following example shows how to call the Control.GetRouteUrl method to get the URL of a route that has parameters that are named productid and category. 此示例假设您已创建了一个HyperLinkHyperLink1为的控件。This example assumes that you have created a HyperLink control that is named HyperLink1.

HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl(  
  New With {.productid = "1", .category = "widgets"})  
HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl(  
  new { productid = "1", category = "widgets" });  

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary)方法。It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary) method. 此方法使用routeParameters RouteValueDictionary 构造函数将传入的对象RouteValueDictionary.RouteValueDictionary(Object)转换为对象。This method converts the object that is passed in routeParameters to a RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor.

另请参阅

GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

public:
 System::String ^ GetRouteUrl(System::Web::Routing::RouteValueDictionary ^ routeParameters);
public string GetRouteUrl (System.Web.Routing.RouteValueDictionary routeParameters);
member this.GetRouteUrl : System.Web.Routing.RouteValueDictionary -> string
Public Function GetRouteUrl (routeParameters As RouteValueDictionary) As String

参数

routeParameters
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

路由参数。The route parameters.

返回

与指定路由参数对应的 URL。The URL that corresponds to the specified route parameters.

示例

下面的示例演示如何调用此方法以获取具有名为productidcategory的参数的路由的 URL。The following example shows how to call this method to get the URL of a route that has parameters that are named productid and category. 此示例假设您已创建了一个HyperLinkHyperLink1为的控件。This example assumes that you have created a HyperLink control that is named HyperLink1.

HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl(  
  new RouteValueDictionary {productId="1", category="widgets"})  
HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl(  
  (new RouteValueDictionary {productId="1", category="widgets"});  

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary)方法。It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary) method.

另请参阅

GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object)

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

public:
 System::String ^ GetRouteUrl(System::String ^ routeName, System::Object ^ routeParameters);
public string GetRouteUrl (string routeName, object routeParameters);
member this.GetRouteUrl : string * obj -> string
Public Function GetRouteUrl (routeName As String, routeParameters As Object) As String

参数

routeName
String String String String

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

routeParameters
Object Object Object Object

路由参数。The route parameters.

返回

与指定路由参数和路由名称对应的 URL。The URL that corresponds to the specified route parameters and route name.

示例

下面的示例演示如何调用此方法以获取名Product为的路由的 URL,并具有名为productidcategory的参数。The following example shows how to call this method to get the URL of a route that is named Product and has parameters that are named productid and category. 此示例假设您已创建了一个HyperLinkHyperLink1为的控件。This example assumes that you have created a HyperLink control that is named HyperLink1.

HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl("Product",  
  New With {.productid = "1", .category = "widgets"})  
HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl("Product",  
  new { productid = "1", category = "widgets" });  

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary)方法。It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary) method. 此方法使用routeParameters RouteValueDictionary 构造函数将传入的对象RouteValueDictionary.RouteValueDictionary(Object)转换为对象。This method converts the object that is passed in routeParameters to a RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor.

另请参阅

GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary)

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

public:
 System::String ^ GetRouteUrl(System::String ^ routeName, System::Web::Routing::RouteValueDictionary ^ routeParameters);
public string GetRouteUrl (string routeName, System.Web.Routing.RouteValueDictionary routeParameters);
member this.GetRouteUrl : string * System.Web.Routing.RouteValueDictionary -> string
Public Function GetRouteUrl (routeName As String, routeParameters As RouteValueDictionary) As String

参数

routeName
String String String String

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

routeParameters
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

路由参数。The route parameters.

返回

与指定路由参数和路由名称对应的 URL。The URL that corresponds to the specified route parameters and route name.

示例

下面的示例演示如何调用此方法以获取名Product为的路由的 URL,并具有名为productidcategory的参数。The following example shows how to call this method to get the URL of a route that is named Product and has parameters that are named productid and category. 此示例假设您已创建了一个HyperLinkHyperLink1为的控件。This example assumes that you have created a HyperLink control that is named HyperLink1.

HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl("Product",  
  new RouteValueDictionary {productId="1", category="widgets"})  
HyperLink1.NavigateUrl = HyperLink1.GetRouteUrl("Product",  
  (new RouteValueDictionary {productId="1", category="widgets"});  

注解

提供此方法是为了便于编码。This method is provided for coding convenience. 它等效于调用RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary)方法。It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary) method.

另请参阅

适用于