Class UrlExtensions
Contains extension methods related to friendly urls for Microsoft.
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. |
htmlHelper | The HTML helper |
Url | url | The URL |
Returns
Type | Description |
---|---|
Microsoft. |
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. |
htmlHelper | The HTML helper |
Url | url | The URL |
Html |
linkArguments | the link attributes such as link text, htmlAttributes, forceAbsolute and forceCanonical |
Returns
Type | Description |
---|---|
Microsoft. |
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. |
htmlHelper | The HTML helper |
Url | url | The URL |
System. |
htmlAttributes | The HTML attributes. |
Returns
Type | Description |
---|---|
Microsoft. |
An anchor tag with the specified url and content name in innerHTML. |
ContentUrl(IUrlHelper, ContentReference)
Resolves an URL using routing for a specific Content
Declaration
public static string ContentUrl(this IUrlHelper urlHelper, ContentReference contentLink)
Parameters
Type | Name | Description |
---|---|---|
Microsoft. |
urlHelper | The URL helper instance that this method extends |
Content |
contentLink | The content reference to resolve |
Returns
Type | Description |
---|---|
System. |
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. |
urlHelper | The URL helper instance that this method extends |
Url | url | The url to resolve |
Returns
Type | Description |
---|---|
System. |
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. |
urlHelper | The URL helper instance that this method extends. |
System. |
classicUrl | The classic URL that should be converted into an hierarchical URL. The URL can be absolute or relative. |
Returns
Type | Description |
---|---|
Microsoft. |
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. |
|
UrlLink(IHtmlHelper, Url)
Declaration
public static IHtmlContent UrlLink(this IHtmlHelper htmlHelper, Url url)
Parameters
Type | Name | Description |
---|---|---|
Microsoft. |
htmlHelper | |
Url | url |
Returns
Type | Description |
---|---|
Microsoft. |
UrlLink(IHtmlHelper, Url, String)
Declaration
public static IHtmlContent UrlLink(this IHtmlHelper htmlHelper, Url url, string linkText)
Parameters
Type | Name | Description |
---|---|---|
Microsoft. |
htmlHelper | |
Url | url | |
System. |
linkText |
Returns
Type | Description |
---|---|
Microsoft. |
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. |
htmlHelper | The HTML helper. |
Url | url | The URL. |
System. |
linkText | The link text. |
System. |
htmlAttributes | The HTML attributes. |
Returns
Type | Description |
---|---|
Microsoft. |
An anchor tag with the specified url. |
Exceptions
Type | Condition |
---|---|
System. |
|