Class UrlExtensions
Contains extension methods related to friendly urls for Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper.
Inheritance
Namespace: EPiServer.Web.Mvc.Html
Assembly: EPiServer.Cms.AspNetCore.HtmlHelpers.dll
Version: 12.0.3Syntax
public static class UrlExtensions : Object
Methods
ContentLink(IHtmlHelper, Url)
Renders a content link. Uses IContent.Name property as an anchor innerHTML
Declaration
public static IHtmlContent ContentLink(this IHtmlHelper htmlHelper, Url url)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper | htmlHelper | The HTML helper |
| Url | url | The URL |
Returns
| Type | Description |
|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | An anchor tag with the specified url and content name in innerHTML. |
ContentLink(IHtmlHelper, Url, HtmlLinkArguments)
Declaration
public static IHtmlContent ContentLink(this IHtmlHelper htmlHelper, Url url, HtmlLinkArguments linkArguments)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper | htmlHelper | The HTML helper |
| Url | url | The URL |
| HtmlLinkArguments | linkArguments | the link attributes such as link text, htmlAttributes, forceAbsolute and forceCanonical |
Returns
| Type | Description |
|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent |
ContentLink(IHtmlHelper, Url, IDictionary<String, Object>)
Renders a content link. Uses IContent.Name property as an anchor innerHTML
Declaration
public static IHtmlContent ContentLink(this IHtmlHelper htmlHelper, Url url, IDictionary<string, object> htmlAttributes)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper | htmlHelper | The HTML helper |
| Url | url | The URL |
| System.Collections.Generic.IDictionary<System.String, System.Object> | htmlAttributes | The HTML attributes. |
Returns
| Type | Description |
|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | An anchor tag with the specified url and content name in innerHTML. |
ContentUrl(IUrlHelper, ContentReference)
Resolves an URL using routing for a specific ContentReference
Declaration
public static string ContentUrl(this IUrlHelper urlHelper, ContentReference contentLink)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Mvc.IUrlHelper | urlHelper | The URL helper instance that this method extends |
| ContentReference | contentLink | The content reference to resolve |
Returns
| Type | Description |
|---|---|
| System.String | The URL or an empty string |
ContentUrl(IUrlHelper, Url)
Resolves an URL using routing for a Url
Declaration
public static string ContentUrl(this IUrlHelper urlHelper, Url url)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Mvc.IUrlHelper | urlHelper | The URL helper instance that this method extends |
| Url | url | The url to resolve |
Returns
| Type | Description |
|---|---|
| System.String | The URL or an empty string |
PageUrl(IUrlHelper, String)
Legacy method: Returns the hierarchical URL representation of a classic URL.
Declaration
public static IHtmlContent PageUrl(this IUrlHelper urlHelper, string classicUrl)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Mvc.IUrlHelper | urlHelper | The URL helper instance that this method extends. |
| System.String | classicUrl | The classic URL that should be converted into an hierarchical URL. The URL can be absolute or relative. |
Returns
| Type | Description |
|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | Depending on the value of
|
Remarks
The string returned does not contain an anchor tag, it only contains the URL.
This method exists for legacy reasons, event though it returns a HtmlString the output is not either HTML or encoded.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
UrlLink(IHtmlHelper, Url)
Declaration
public static IHtmlContent UrlLink(this IHtmlHelper htmlHelper, Url url)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper | htmlHelper | |
| Url | url |
Returns
| Type | Description |
|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent |
UrlLink(IHtmlHelper, Url, String)
Declaration
public static IHtmlContent UrlLink(this IHtmlHelper htmlHelper, Url url, string linkText)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper | htmlHelper | |
| Url | url | |
| System.String | linkText |
Returns
| Type | Description |
|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent |
UrlLink(IHtmlHelper, Url, String, IDictionary<String, Object>)
Returns an anchor tag with the specified url.
Declaration
public static IHtmlContent UrlLink(this IHtmlHelper htmlHelper, Url url, string linkText, IDictionary<string, object> htmlAttributes)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper | htmlHelper | The HTML helper. |
| Url | url | The URL. |
| System.String | linkText | The link text. |
| System.Collections.Generic.IDictionary<System.String, System.Object> | htmlAttributes | The HTML attributes. |
Returns
| Type | Description |
|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | An anchor tag with the specified url. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|