UrlHelper.Action Method

 

Generates a fully qualified URL to an action method.

Namespace:   System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Overload List

Name Description
System_CAPS_pubmethod Action()

Generates a string to a fully qualified URL to an action method.

System_CAPS_pubmethod Action(String)

Generates a fully qualified URL to an action method by using the specified action name.

System_CAPS_pubmethod Action(String, Object)

Generates a fully qualified URL to an action method by using the specified action name and route values.

System_CAPS_pubmethod Action(String, RouteValueDictionary)

Generates a fully qualified URL to an action method for the specified action name and route values.

System_CAPS_pubmethod Action(String, String)

Generates a fully qualified URL to an action method by using the specified action name and controller name.

System_CAPS_pubmethod Action(String, String, Object)

Generates a fully qualified URL to an action method by using the specified action name, controller name, and route values.

System_CAPS_pubmethod Action(String, String, Object, String)

Generates a fully qualified URL to an action method by using the specified action name, controller name, route values, and protocol to use.

System_CAPS_pubmethod Action(String, String, RouteValueDictionary)

Generates a fully qualified URL to an action method by using the specified action name, controller name, and route values.

System_CAPS_pubmethod Action(String, String, RouteValueDictionary, String)

Generates a fully qualified URL for an action method by using the specified action name, controller name, route values, and protocol to use.

System_CAPS_pubmethod Action(String, String, RouteValueDictionary, String, String)

Generates a fully qualified URL for an action method by using the specified action name, controller name, route values, protocol to use and host name.

See Also

UrlHelper Class
System.Web.Mvc Namespace

Return to top

UrlHelper.Action Method ()

Generates a string to a fully qualified URL to an action method.

Syntax

public virtual string Action()
public:
virtual String^ Action()
abstract Action : unit -> string
override Action : unit -> string
Public Overridable Function Action As String

Return Value

Type: System.String

A string to a fully qualified URL to an action method.

Remarks

The URL that is returned by this method has a format like the following:

/Home/About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

Return to top

UrlHelper.Action Method (String)

Generates a fully qualified URL to an action method by using the specified action name.

Syntax

public virtual string Action(
    string actionName
)
public:
virtual String^ Action(
    String^ actionName
)
abstract Action : 
        actionName:string -> string
override Action : 
        actionName:string -> string
Public Overridable Function Action (
    actionName As String
) As String

Parameters

Return Value

Type: System.String

The fully qualified URL to an action method.

Remarks

The URL that is returned by this method has a format like the following:

/Home/About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

Return to top

UrlHelper.Action Method (String, Object)

Generates a fully qualified URL to an action method by using the specified action name and route values.

Syntax

public virtual string Action(
    string actionName,
    object routeValues
)
public:
virtual String^ Action(
    String^ actionName,
    Object^ routeValues
)
abstract Action : 
        actionName:string *
        routeValues:Object -> string
override Action : 
        actionName:string *
        routeValues:Object -> string
Public Overridable Function Action (
    actionName As String,
    routeValues As Object
) As String

Parameters

  • routeValues
    Type: System.Object

    An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

Return Value

Type: System.String

The fully qualified URL to an action method.

Remarks

The URL that is returned by this method has a format like the following:

/Home/About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

Return to top

UrlHelper.Action Method (String, RouteValueDictionary)

Generates a fully qualified URL to an action method for the specified action name and route values.

Syntax

public virtual string Action(
    string actionName,
    RouteValueDictionary routeValues
)
public:
virtual String^ Action(
    String^ actionName,
    RouteValueDictionary^ routeValues
)
abstract Action : 
        actionName:string *
        routeValues:RouteValueDictionary -> string
override Action : 
        actionName:string *
        routeValues:RouteValueDictionary -> string
Public Overridable Function Action (
    actionName As String,
    routeValues As RouteValueDictionary
) As String

Parameters

Return Value

Type: System.String

The fully qualified URL to an action method.

Remarks

The URL that is returned by this method has a format like the following:

/Home/About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

Return to top

UrlHelper.Action Method (String, String)

Generates a fully qualified URL to an action method by using the specified action name and controller name.

Syntax

public virtual string Action(
    string actionName,
    string controllerName
)
public:
virtual String^ Action(
    String^ actionName,
    String^ controllerName
)
abstract Action : 
        actionName:string *
        controllerName:string -> string
override Action : 
        actionName:string *
        controllerName:string -> string
Public Overridable Function Action (
    actionName As String,
    controllerName As String
) As String

Parameters

Return Value

Type: System.String

The fully qualified URL to an action method.

Remarks

The URL that is returned by this method has a format like the following:

/Home/About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

Return to top

UrlHelper.Action Method (String, String, Object)

Generates a fully qualified URL to an action method by using the specified action name, controller name, and route values.

Syntax

public virtual string Action(
    string actionName,
    string controllerName,
    object routeValues
)
public:
virtual String^ Action(
    String^ actionName,
    String^ controllerName,
    Object^ routeValues
)
abstract Action : 
        actionName:string *
        controllerName:string *
        routeValues:Object -> string
override Action : 
        actionName:string *
        controllerName:string *
        routeValues:Object -> string
Public Overridable Function Action (
    actionName As String,
    controllerName As String,
    routeValues As Object
) As String

Parameters

  • routeValues
    Type: System.Object

    An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

Return Value

Type: System.String

The fully qualified URL to an action method.

Remarks

The URL that is returned by this method has a format like the following:

/Home/About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

Return to top

UrlHelper.Action Method (String, String, Object, String)

Generates a fully qualified URL to an action method by using the specified action name, controller name, route values, and protocol to use.

Syntax

public virtual string Action(
    string actionName,
    string controllerName,
    object routeValues,
    string protocol
)
public:
virtual String^ Action(
    String^ actionName,
    String^ controllerName,
    Object^ routeValues,
    String^ protocol
)
abstract Action : 
        actionName:string *
        controllerName:string *
        routeValues:Object *
        protocol:string -> string
override Action : 
        actionName:string *
        controllerName:string *
        routeValues:Object *
        protocol:string -> string
Public Overridable Function Action (
    actionName As String,
    controllerName As String,
    routeValues As Object,
    protocol As String
) As String

Parameters

  • routeValues
    Type: System.Object

    An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

  • protocol
    Type: System.String

    The protocol for the URL, such as "http" or "https".

Return Value

Type: System.String

The fully qualified URL to an action method.

Remarks

The URL that is returned by this method has a format like the following:

/Home/About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

Return to top

UrlHelper.Action Method (String, String, RouteValueDictionary)

Generates a fully qualified URL to an action method by using the specified action name, controller name, and route values.

Syntax

public virtual string Action(
    string actionName,
    string controllerName,
    RouteValueDictionary routeValues
)
public:
virtual String^ Action(
    String^ actionName,
    String^ controllerName,
    RouteValueDictionary^ routeValues
)
abstract Action : 
        actionName:string *
        controllerName:string *
        routeValues:RouteValueDictionary -> string
override Action : 
        actionName:string *
        controllerName:string *
        routeValues:RouteValueDictionary -> string
Public Overridable Function Action (
    actionName As String,
    controllerName As String,
    routeValues As RouteValueDictionary
) As String

Parameters

Return Value

Type: System.String

The fully qualified URL to an action method.

Remarks

The URL that is returned by this method has a format like the following:

/Home/About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

Return to top

UrlHelper.Action Method (String, String, RouteValueDictionary, String)

Generates a fully qualified URL for an action method by using the specified action name, controller name, route values, and protocol to use.

Syntax

public virtual string Action(
    string actionName,
    string controllerName,
    RouteValueDictionary routeValues,
    string protocol
)
public:
virtual String^ Action(
    String^ actionName,
    String^ controllerName,
    RouteValueDictionary^ routeValues,
    String^ protocol
)
abstract Action : 
        actionName:string *
        controllerName:string *
        routeValues:RouteValueDictionary *
        protocol:string -> string
override Action : 
        actionName:string *
        controllerName:string *
        routeValues:RouteValueDictionary *
        protocol:string -> string
Public Overridable Function Action (
    actionName As String,
    controllerName As String,
    routeValues As RouteValueDictionary,
    protocol As String
) As String

Parameters

  • protocol
    Type: System.String

    The protocol for the URL, such as "http" or "https".

Return Value

Type: System.String

The fully qualified URL to an action method.

Return to top

UrlHelper.Action Method (String, String, RouteValueDictionary, String, String)

Generates a fully qualified URL for an action method by using the specified action name, controller name, route values, protocol to use and host name.

Syntax

public virtual string Action(
    string actionName,
    string controllerName,
    RouteValueDictionary routeValues,
    string protocol,
    string hostName
)
public:
virtual String^ Action(
    String^ actionName,
    String^ controllerName,
    RouteValueDictionary^ routeValues,
    String^ protocol,
    String^ hostName
)
abstract Action : 
        actionName:string *
        controllerName:string *
        routeValues:RouteValueDictionary *
        protocol:string *
        hostName:string -> string
override Action : 
        actionName:string *
        controllerName:string *
        routeValues:RouteValueDictionary *
        protocol:string *
        hostName:string -> string
Public Overridable Function Action (
    actionName As String,
    controllerName As String,
    routeValues As RouteValueDictionary,
    protocol As String,
    hostName As String
) As String

Parameters

  • protocol
    Type: System.String

    The protocol for the URL, such as "http" or "https".

Return Value

Type: System.String

The fully qualified URL to an action method.

Remarks

The URL that is returned by this method has a format like the following:

/Home/About

If special characters in the URL must be encoded, use the Encode method. For the previous example, the Encode method returns the following URL:

%2fHome%2fAbout

Return to top