IUrlHelper Interface

Summary

Defines the contract for the helper to build URLs for ASP.NET MVC within an application.

Syntax

public interface IUrlHelper

GitHub

View on GitHub

interface Microsoft.AspNet.Mvc.IUrlHelper

Methods

Action(Microsoft.AspNet.Mvc.UrlActionContext)

Generates a fully qualified or absolute URL specified by [Microsoft.AspNet.Mvc.UrlActionContext](Microsoft.AspNet.Mvc.UrlActionContext.yml) for an action method, which contains action name, controller name, route values, protocol to use, host name, and fragment.

Arguments:
Return type:

System.String

Returns:

The fully qualified or absolute URL to an action method.

string Action(UrlActionContext actionContext)
Content(System.String)

Converts a virtual (relative) path to an application absolute path.

Arguments:
  • contentPath (System.String) – The virtual path of the content.
Return type:

System.String

Returns:

The application absolute path.

string Content(string contentPath)
IsLocalUrl(System.String)

Returns a value that indicates whether the URL is local. An URL with an absolute path is considered local if it does not have a host/authority part. URLs using the virtual paths (‘~/’) are also local.

Arguments:
  • url (System.String) – The URL.
Return type:

System.Boolean

Returns:

<c>true</c> if the URL is local; otherwise, <c>false</c>.

bool IsLocalUrl(string url)

Generates an absolute URL using the specified route name and values.

Arguments:
  • routeName (System.String) – The name of the route that is used to generate the URL.
  • values (System.Object) – An object that contains the route values.
Return type:

System.String

Returns:

The generated absolute URL.

string Link(string routeName, object values)
RouteUrl(Microsoft.AspNet.Mvc.UrlRouteContext)

Generates a fully qualified or absolute URL specified by [Microsoft.AspNet.Mvc.UrlRouteContext](Microsoft.AspNet.Mvc.UrlRouteContext.yml), which contains the route name, the route values, protocol to use, host name and fragment.

Arguments:
Return type:

System.String

Returns:

The fully qualified or absolute URL.

string RouteUrl(UrlRouteContext routeContext)