Class UrlExtensions
Contains extension methods related to friendly urls for System.Web.Mvc.UrlHelper.
Inheritance
Inherited Members
Namespace: EPiServer.Web.Mvc.Html
Assembly: EPiServer.dll
Version: 8.11.0Syntax
public static class UrlExtensions
Methods
ContentLink(HtmlHelper, Url)
Renders a content link. Uses IContent.Name property as an anchor innerHTML
Declaration
public static MvcHtmlString ContentLink(this HtmlHelper htmlHelper, Url url)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Mvc.HtmlHelper | htmlHelper | The HTML helper |
Url | url | The URL |
Returns
Type | Description |
---|---|
System.Web.Mvc.MvcHtmlString | An anchor tag with the specified url and content name in innerHTML. |
ContentLink(HtmlHelper, Url, IDictionary<String, Object>)
Renders a content link. Uses IContent.Name property as an anchor innerHTML
Declaration
public static MvcHtmlString ContentLink(this HtmlHelper htmlHelper, Url url, IDictionary<string, object> htmlAttributes)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Mvc.HtmlHelper | htmlHelper | The HTML helper |
Url | url | The URL |
System.Collections.Generic.IDictionary<System.String, System.Object> | htmlAttributes | The HTML attributes. |
Returns
Type | Description |
---|---|
System.Web.Mvc.MvcHtmlString | An anchor tag with the specified url and content name in innerHTML. |
ContentUrl(UrlHelper, ContentReference)
Resolves an URL using routing for a specific ContentReference
Declaration
public static string ContentUrl(this UrlHelper urlHelper, ContentReference contentLink)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Mvc.UrlHelper | 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(UrlHelper, Url)
Resolves an URL using routing for a Url
Declaration
public static string ContentUrl(this UrlHelper urlHelper, Url url)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Mvc.UrlHelper | 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(UrlHelper, String)
Legacy method: Returns the hierarchical URL representation of a classic URL.
Declaration
public static MvcHtmlString PageUrl(this UrlHelper urlHelper, string classicUrl)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Mvc.UrlHelper | 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 |
---|---|
System.Web.Mvc.MvcHtmlString | 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 MvcHtmlString the output is not either HTML or encoded.
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
UrlLink(HtmlHelper, Url)
Declaration
public static MvcHtmlString UrlLink(this HtmlHelper htmlHelper, Url url)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Mvc.HtmlHelper | htmlHelper | |
Url | url |
Returns
Type | Description |
---|---|
System.Web.Mvc.MvcHtmlString |
UrlLink(HtmlHelper, Url, String)
Declaration
public static MvcHtmlString UrlLink(this HtmlHelper htmlHelper, Url url, string linkText)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Mvc.HtmlHelper | htmlHelper | |
Url | url | |
System.String | linkText |
Returns
Type | Description |
---|---|
System.Web.Mvc.MvcHtmlString |
UrlLink(HtmlHelper, Url, String, IDictionary<String, Object>)
Returns an anchor tag with the specified url.
Declaration
public static MvcHtmlString UrlLink(this HtmlHelper htmlHelper, Url url, string linkText, IDictionary<string, object> htmlAttributes)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Mvc.HtmlHelper | 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 |
---|---|
System.Web.Mvc.MvcHtmlString | An anchor tag with the specified url. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|