Delen via


UrlHelper.RouteUrl Method (String, Object)

Generates a fully qualified URL for the specified route values by using a route name.

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Syntax

'Declaration
Public Function RouteUrl ( _
    routeName As String, _
    routeValues As Object _
) As String
public string RouteUrl(
    string routeName,
    Object routeValues
)
public:
String^ RouteUrl(
    String^ routeName, 
    Object^ routeValues
)

Parameters

  • routeName
    Type: System.String
    The name of the route that is used to generate the URL.
  • routeValues
    Type: System.Object
    An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

Return Value

Type: System.String
The fully qualified URL.

Remarks

The URL that is returned by this method has a format like the following:

\Home\About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

See Also

Reference

UrlHelper Class

RouteUrl Overload

System.Web.Mvc Namespace