UrlHelper Class¶
Summary¶
An implementation of [Microsoft.AspNet.Mvc.IUrlHelper](Microsoft.AspNet.Mvc.IUrlHelper.yml) that contains methods to build URLs for ASP.NET MVC within an application.
Inheritance Hierarchy¶
System.Object
Microsoft.AspNet.Mvc.UrlHelper
Constructors¶
-
UrlHelper
(Microsoft.AspNet.Mvc.IScopedInstance<Microsoft.AspNet.Mvc.ActionContext>, Microsoft.AspNet.Mvc.IActionSelector)¶ Initializes a new instance of the [Microsoft.AspNet.Mvc.UrlHelper](Microsoft.AspNet.Mvc.UrlHelper.yml) class using the specified action context and action selector.
Arguments: - contextAccessor (Microsoft.AspNet.Mvc.IScopedInstance{Microsoft.AspNet.Mvc.ActionContext}) – The [Microsoft.AspNet.Mvc.IScopedInstance`1](Microsoft.AspNet.Mvc.IScopedInstance`1.yml) to access the action context of the current request.
- actionSelector (Microsoft.AspNet.Mvc.IActionSelector) – The [Microsoft.AspNet.Mvc.IActionSelector](Microsoft.AspNet.Mvc.IActionSelector.yml) to be used for verifying the correctness of supplied parameters for a route.
public UrlHelper(IScopedInstance<ActionContext> contextAccessor, IActionSelector actionSelector)
-
Methods¶
-
Action
(Microsoft.AspNet.Mvc.UrlActionContext)¶ Arguments: - actionContext (Microsoft.AspNet.Mvc.UrlActionContext) –
Return type: System.String
public virtual string Action(UrlActionContext actionContext)
-
Content
(System.String)¶ Arguments: - contentPath (System.String) –
Return type: System.String
public virtual string Content(string contentPath)
-
GeneratePathFromRoute
(System.String, System.Collections.Generic.IDictionary<System.String, System.Object>)¶ Generates the absolute path of the url for the specified route values by using the specified route name.
Arguments: - routeName (System.String) – The name of the route that is used to generate the URL.
- values (System.Collections.Generic.IDictionary{System.String,System.Object}) – A dictionary that contains the parameters for a route.
Return type: System.String
Returns: The absolute path of the URL.
protected virtual string GeneratePathFromRoute(string routeName, IDictionary<string, object> values)
-
IsLocalUrl
(System.String)¶ Arguments: - url (System.String) –
Return type: System.Boolean
public bool IsLocalUrl(string url)
-
Link
(System.String, System.Object)¶ Arguments: - routeName (System.String) –
- values (System.Object) –
Return type: System.String
public virtual string Link(string routeName, object values)
-
RouteUrl
(Microsoft.AspNet.Mvc.UrlRouteContext)¶ Arguments: - routeContext (Microsoft.AspNet.Mvc.UrlRouteContext) –
Return type: System.String
public virtual string RouteUrl(UrlRouteContext routeContext)
-