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

Definition

Gets the URL that corresponds to a set of route parameters, and optionally to a route name.

Overloads

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

Gets the URL that corresponds to a set of route parameters.

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

Gets the URL that corresponds to a set of route parameters.

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

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)

Gets the URL that corresponds to a set of route parameters and a route name.

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath method.

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

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

Parameters

routeParameters
Object Object Object Object

The route parameters.

Returns

The URL that corresponds to the specified route parameters.

Examples

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. 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" });  

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary) method. This method converts the object that is passed in routeParameters to a RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor.

See Also

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

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

Parameters

Returns

The URL that corresponds to the specified route parameters.

Examples

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. 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"});  

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, RouteValueDictionary) method.

See Also

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

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

Parameters

routeName
String String String String

The name of the route.

routeParameters
Object Object Object Object

The route parameters.

Returns

The URL that corresponds to the specified route parameters and route name.

Examples

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. 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" });  

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary) method. This method converts the object that is passed in routeParameters to a RouteValueDictionary object by using the RouteValueDictionary.RouteValueDictionary(Object) constructor.

See Also

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

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

Parameters

routeName
String String String String

The name of the route.

Returns

The URL that corresponds to the specified route parameters and route name.

Examples

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. 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"});  

Remarks

This method is provided for coding convenience. It is equivalent to calling the RouteCollection.GetVirtualPath(RequestContext, String, RouteValueDictionary) method.

See Also

Applies to