Table of Contents

Class UrlHelperExtensions

Namespace
Umbraco.Extensions
Assembly
Umbraco.Web.Common.dll
public static class UrlHelperExtensions
Inheritance
UrlHelperExtensions
Inherited Members

Methods

GetCacheBustHash(IHostingEnvironment, IUmbracoVersion)

public static string GetCacheBustHash(IHostingEnvironment hostingEnvironment, IUmbracoVersion umbracoVersion)

Parameters

hostingEnvironment IHostingEnvironment
umbracoVersion IUmbracoVersion

Returns

string

GetCropUrl(IUrlHelper, IPublishedContent?, int?, int?, string, string?, int?, ImageCropMode?, ImageCropAnchor?, bool, bool, bool, string?, bool, UrlMode)

public static IHtmlContent GetCropUrl(this IUrlHelper urlHelper, IPublishedContent? mediaItem, int? width = null, int? height = null, string propertyAlias = "umbracoFile", string? cropAlias = null, int? quality = null, ImageCropMode? imageCropMode = null, ImageCropAnchor? imageCropAnchor = null, bool preferFocalPoint = false, bool useCropDimensions = false, bool cacheBuster = true, string? furtherOptions = null, bool htmlEncode = true, UrlMode urlMode = 0)

Parameters

urlHelper IUrlHelper
mediaItem IPublishedContent
width int?
height int?
propertyAlias string
cropAlias string
quality int?
imageCropMode ImageCropMode?
imageCropAnchor ImageCropAnchor?
preferFocalPoint bool
useCropDimensions bool
cacheBuster bool
furtherOptions string
htmlEncode bool
urlMode UrlMode

Returns

IHtmlContent

GetCropUrl(IUrlHelper, IPublishedContent?, string, bool, UrlMode)

public static IHtmlContent GetCropUrl(this IUrlHelper urlHelper, IPublishedContent? mediaItem, string cropAlias, bool htmlEncode = true, UrlMode urlMode = 0)

Parameters

urlHelper IUrlHelper
mediaItem IPublishedContent
cropAlias string
htmlEncode bool
urlMode UrlMode

Returns

IHtmlContent

GetCropUrl(IUrlHelper, IPublishedContent?, string, string, bool, UrlMode)

public static IHtmlContent GetCropUrl(this IUrlHelper urlHelper, IPublishedContent? mediaItem, string propertyAlias, string cropAlias, bool htmlEncode = true, UrlMode urlMode = 0)

Parameters

urlHelper IUrlHelper
mediaItem IPublishedContent
propertyAlias string
cropAlias string
htmlEncode bool
urlMode UrlMode

Returns

IHtmlContent

GetCropUrl(IUrlHelper, ImageCropperValue?, string, int?, int?, int?, ImageCropMode?, ImageCropAnchor?, bool, bool, string?, string?, bool)

public static IHtmlContent GetCropUrl(this IUrlHelper urlHelper, ImageCropperValue? imageCropperValue, string cropAlias, int? width = null, int? height = null, int? quality = null, ImageCropMode? imageCropMode = null, ImageCropAnchor? imageCropAnchor = null, bool preferFocalPoint = false, bool useCropDimensions = true, string? cacheBusterValue = null, string? furtherOptions = null, bool htmlEncode = true)

Parameters

urlHelper IUrlHelper
imageCropperValue ImageCropperValue
cropAlias string
width int?
height int?
quality int?
imageCropMode ImageCropMode?
imageCropAnchor ImageCropAnchor?
preferFocalPoint bool
useCropDimensions bool
cacheBusterValue string
furtherOptions string
htmlEncode bool

Returns

IHtmlContent

GetUmbracoApiService(IUrlHelper, string, string, object?)

Return the Url for a Web Api service

public static string? GetUmbracoApiService(this IUrlHelper url, string actionName, string controllerName, object? id = null)

Parameters

url IUrlHelper
actionName string
controllerName string
id object

Returns

string

GetUmbracoApiService(IUrlHelper, string, string, string, object?)

Return the Url for a Web Api service

public static string? GetUmbracoApiService(this IUrlHelper url, string actionName, string controllerName, string area, object? id = null)

Parameters

url IUrlHelper
actionName string
controllerName string
area string
id object

Returns

string

GetUmbracoApiService(IUrlHelper, UmbracoApiControllerTypeCollection, string, Type, object?)

Return the Url for a Web Api service

[Obsolete("This will be removed in Umbraco 15.")]
public static string? GetUmbracoApiService(this IUrlHelper url, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, string actionName, Type apiControllerType, object? id = null)

Parameters

url IUrlHelper
umbracoApiControllerTypeCollection UmbracoApiControllerTypeCollection
actionName string
apiControllerType Type
id object

Returns

string

GetUmbracoApiServiceBaseUrl<T>(IUrlHelper, UmbracoApiControllerTypeCollection, Expression<Func<T, object>>)

[Obsolete("This will be removed in Umbraco 15.")]
public static string? GetUmbracoApiServiceBaseUrl<T>(this IUrlHelper url, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, Expression<Func<T, object>> methodSelector) where T : UmbracoApiController

Parameters

url IUrlHelper
umbracoApiControllerTypeCollection UmbracoApiControllerTypeCollection
methodSelector Expression<Func<T, object>>

Returns

string

Type Parameters

T

GetUmbracoApiServiceBaseUrl<T>(IUrlHelper, UmbracoApiControllerTypeCollection, string)

Return the Base Url (not including the action) for a Web Api service

[Obsolete("This will be removed in Umbraco 15.")]
public static string? GetUmbracoApiServiceBaseUrl<T>(this IUrlHelper url, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, string actionName) where T : UmbracoApiController

Parameters

url IUrlHelper
umbracoApiControllerTypeCollection UmbracoApiControllerTypeCollection
actionName string

Returns

string

Type Parameters

T

GetUmbracoApiService<T>(IUrlHelper, UmbracoApiControllerTypeCollection, Expression<Func<T, object>>)

[Obsolete("This will be removed in Umbraco 15.")]
public static string? GetUmbracoApiService<T>(this IUrlHelper url, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, Expression<Func<T, object>> methodSelector) where T : UmbracoApiController

Parameters

url IUrlHelper
umbracoApiControllerTypeCollection UmbracoApiControllerTypeCollection
methodSelector Expression<Func<T, object>>

Returns

string

Type Parameters

T

GetUmbracoApiService<T>(IUrlHelper, UmbracoApiControllerTypeCollection, string, object?)

Return the Url for a Web Api service

[Obsolete("This will be removed in Umbraco 15.")]
public static string? GetUmbracoApiService<T>(this IUrlHelper url, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, string actionName, object? id = null) where T : UmbracoApiController

Parameters

url IUrlHelper
umbracoApiControllerTypeCollection UmbracoApiControllerTypeCollection
actionName string
id object

Returns

string

Type Parameters

T

GetUrlWithCacheBust(IUrlHelper, string, string, RouteValueDictionary, IHostingEnvironment, IUmbracoVersion)

Return the Url for an action with a cache-busting hash appended

public static string GetUrlWithCacheBust(this IUrlHelper url, string actionName, string controllerName, RouteValueDictionary routeVals, IHostingEnvironment hostingEnvironment, IUmbracoVersion umbracoVersion)

Parameters

url IUrlHelper
actionName string
controllerName string
routeVals RouteValueDictionary
hostingEnvironment IHostingEnvironment
umbracoVersion IUmbracoVersion

Returns

string

SurfaceAction(IUrlHelper, IUmbracoContext, IDataProtectionProvider, string, string)

Generates a URL based on the current Umbraco URL with a custom query string that will route to the specified SurfaceController

public static string SurfaceAction(this IUrlHelper url, IUmbracoContext umbracoContext, IDataProtectionProvider dataProtectionProvider, string action, string controllerName)

Parameters

url IUrlHelper
umbracoContext IUmbracoContext
dataProtectionProvider IDataProtectionProvider
action string
controllerName string

Returns

string

SurfaceAction(IUrlHelper, IUmbracoContext, IDataProtectionProvider, string, string, object?)

Generates a URL based on the current Umbraco URL with a custom query string that will route to the specified SurfaceController

public static string SurfaceAction(this IUrlHelper url, IUmbracoContext umbracoContext, IDataProtectionProvider dataProtectionProvider, string action, string controllerName, object? additionalRouteVals)

Parameters

url IUrlHelper
umbracoContext IUmbracoContext
dataProtectionProvider IDataProtectionProvider
action string
controllerName string
additionalRouteVals object

Returns

string

SurfaceAction(IUrlHelper, IUmbracoContext, IDataProtectionProvider, string, string, string, object?)

Generates a URL based on the current Umbraco URL with a custom query string that will route to the specified SurfaceController

public static string SurfaceAction(this IUrlHelper url, IUmbracoContext umbracoContext, IDataProtectionProvider dataProtectionProvider, string action, string controllerName, string area, object? additionalRouteVals)

Parameters

url IUrlHelper
umbracoContext IUmbracoContext
dataProtectionProvider IDataProtectionProvider
action string
controllerName string
area string
additionalRouteVals object

Returns

string