Export (0) Print
Expand All

HtmlHelper.GenerateRouteLink Method (RequestContext, RouteCollection, String, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>)

Generates an HTML anchor element (a element) that links to the specified URL route.

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

public static string GenerateRouteLink(
	RequestContext requestContext,
	RouteCollection routeCollection,
	string linkText,
	string routeName,
	string protocol,
	string hostName,
	string fragment,
	RouteValueDictionary routeValues,
	IDictionary<string, Object> htmlAttributes
)

Parameters

requestContext
Type: System.Web.Routing.RequestContext
The context of the HTTP request.
routeCollection
Type: System.Web.Routing.RouteCollection
The collection of URL routes.
linkText
Type: System.String
The text caption displayed for the link.
routeName
Type: System.String
The name of the route that is used to return a virtual path.
protocol
Type: System.String
The communication protocol, such as "http" or "https". If null, the protocol will default to http.
hostName
Type: System.String
The name of the host.
fragment
Type: System.String
The fragment identifier.
routeValues
Type: System.Web.Routing.RouteValueDictionary
An object that contains the parameters for a route.
htmlAttributes
Type: System.Collections.Generic.IDictionary<String, Object>
An object that contains the HTML attributes for the element..

Return Value

Type: System.String
An HTML tag that links to the specified URL route.

The LinkExtensions class contains a RouteLink method with several overloads that provide additional options for creating links to URL routes.

Community Additions

Show:
© 2014 Microsoft