UrlHelper Class¶
An implementation of Microsoft.AspNetCore.Mvc.IUrlHelper
that contains methods to
build URLs for ASP.NET MVC within an application.
- Namespace
Microsoft.AspNetCore.Mvc.Routing
- Assemblies
- Microsoft.AspNetCore.Mvc.Core
Constructors¶
-
UrlHelper
(Microsoft.AspNetCore.Mvc.ActionContext)¶ Initializes a new instance of the
Microsoft.AspNetCore.Mvc.Routing.UrlHelper
class using the specified action context and action selector.Arguments: actionContext (Microsoft.AspNetCore.Mvc.ActionContext) – The Microsoft.AspNetCore.Mvc.ActionContext
for the current request.public UrlHelper(ActionContext actionContext)
-
Methods¶
-
Action
(Microsoft.AspNetCore.Mvc.Routing.UrlActionContext)¶ Return type: System.String public virtual string Action(UrlActionContext actionContext)
-
Content
(System.String)¶ Return type: System.String public virtual string Content(string contentPath)
-
GenerateUrl
(System.String, System.String, Microsoft.AspNetCore.Routing.VirtualPathData, System.String)¶ Generates the URL using the specified components.
Arguments: - protocol (System.String) – The protocol.
- host (System.String) – The host.
- pathData (Microsoft.AspNetCore.Routing.VirtualPathData) – The
Microsoft.AspNetCore.Routing.VirtualPathData
. - fragment (System.String) – The URL fragment.
Return type: System.String
Returns: The generated URL.
protected virtual string GenerateUrl(string protocol, string host, VirtualPathData pathData, string fragment)
-
GetVirtualPathData
(System.String, Microsoft.AspNetCore.Routing.RouteValueDictionary)¶ Gets the
Microsoft.AspNetCore.Routing.VirtualPathData
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
Microsoft.AspNetCore.Routing.VirtualPathData
. - values (Microsoft.AspNetCore.Routing.RouteValueDictionary) – A dictionary that contains the parameters for a route.
Return type: Returns: protected virtual VirtualPathData GetVirtualPathData(string routeName, RouteValueDictionary values)
- routeName (System.String) – The name of the route that is used to generate the
-
IsLocalUrl
(System.String)¶ Return type: System.Boolean public virtual bool IsLocalUrl(string url)
-
Link
(System.String, System.Object)¶ Return type: System.String public virtual string Link(string routeName, object values)
-
RouteUrl
(Microsoft.AspNetCore.Mvc.Routing.UrlRouteContext)¶ Return type: System.String public virtual string RouteUrl(UrlRouteContext routeContext)
-
Properties¶
-
Microsoft.AspNetCore.Mvc.Routing.UrlHelper.
ActionContext
¶ Return type: Microsoft.AspNetCore.Mvc.ActionContext public ActionContext ActionContext { get; }
-
Microsoft.AspNetCore.Mvc.Routing.UrlHelper.
AmbientValues
¶ Return type: Microsoft.AspNetCore.Routing.RouteValueDictionary protected RouteValueDictionary AmbientValues { get; }
-
Microsoft.AspNetCore.Mvc.Routing.UrlHelper.
HttpContext
¶ Return type: Microsoft.AspNetCore.Http.HttpContext protected HttpContext HttpContext { get; }
-
Microsoft.AspNetCore.Mvc.Routing.UrlHelper.
Router
¶ Return type: Microsoft.AspNetCore.Routing.IRouter protected IRouter Router { get; }
-