Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ControllerLinkGeneratorExtensions.GetPathByAction Method

Definition

Namespace:
Microsoft.AspNetCore.Routing
Assembly:
Microsoft.AspNetCore.Mvc.Core.dll
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.Mvc.Core v2.2.0
Package:
Microsoft.AspNetCore.App.Ref v3.0.1
Package:
Microsoft.AspNetCore.App.Ref v3.1.10
Package:
Microsoft.AspNetCore.App.Ref v5.0.0
Package:
Microsoft.AspNetCore.App.Ref v6.0.36
Package:
Microsoft.AspNetCore.App.Ref v7.0.5
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
GetPathByAction(LinkGenerator, String, String, Object, PathString, FragmentString, LinkOptions)

Generates a URI with an absolute path based on the provided values.

GetPathByAction(LinkGenerator, HttpContext, String, String, Object, Nullable<PathString>, FragmentString, LinkOptions)

Generates a URI with an absolute path based on the provided values.

GetPathByAction(LinkGenerator, String, String, Object, PathString, FragmentString, LinkOptions)

Source:
ControllerLinkGeneratorExtensions.cs
Source:
ControllerLinkGeneratorExtensions.cs

Generates a URI with an absolute path based on the provided values.

public static string? GetPathByAction(this Microsoft.AspNetCore.Routing.LinkGenerator generator, string action, string controller, object? values = default, Microsoft.AspNetCore.Http.PathString pathBase = default, Microsoft.AspNetCore.Http.FragmentString fragment = default, Microsoft.AspNetCore.Routing.LinkOptions? options = default);
public static string GetPathByAction(this Microsoft.AspNetCore.Routing.LinkGenerator generator, string action, string controller, object values = default, Microsoft.AspNetCore.Http.PathString pathBase = default, Microsoft.AspNetCore.Http.FragmentString fragment = default, Microsoft.AspNetCore.Routing.LinkOptions options = default);
static member GetPathByAction : Microsoft.AspNetCore.Routing.LinkGenerator * string * string * obj * Microsoft.AspNetCore.Http.PathString * Microsoft.AspNetCore.Http.FragmentString * Microsoft.AspNetCore.Routing.LinkOptions -> string
<Extension()>
Public Function GetPathByAction (generator As LinkGenerator, action As String, controller As String, Optional values As Object = Nothing, Optional pathBase As PathString = Nothing, Optional fragment As FragmentString = Nothing, Optional options As LinkOptions = Nothing) As String

Parameters

generator
LinkGenerator

The LinkGenerator.

action
String

The action name. Used to resolve endpoints.

controller
String

The controller name. Used to resolve endpoints.

values
Object

The route values. Optional. Used to resolve endpoints and expand parameters in the route template.

pathBase
PathString

An optional URI path base. Prepended to the path in the resulting URI.

fragment
FragmentString

A URI fragment. Optional. Appended to the resulting URI.

options
LinkOptions

An optional LinkOptions. Settings on provided object override the settings with matching names from RouteOptions.

Returns

A URI with an absolute path, or null if a URI cannot be created.

Applies to

GetPathByAction(LinkGenerator, HttpContext, String, String, Object, Nullable<PathString>, FragmentString, LinkOptions)

Source:
ControllerLinkGeneratorExtensions.cs
Source:
ControllerLinkGeneratorExtensions.cs

Generates a URI with an absolute path based on the provided values.

public static string? GetPathByAction(this Microsoft.AspNetCore.Routing.LinkGenerator generator, Microsoft.AspNetCore.Http.HttpContext httpContext, string? action = default, string? controller = default, object? values = default, Microsoft.AspNetCore.Http.PathString? pathBase = default, Microsoft.AspNetCore.Http.FragmentString fragment = default, Microsoft.AspNetCore.Routing.LinkOptions? options = default);
public static string GetPathByAction(this Microsoft.AspNetCore.Routing.LinkGenerator generator, Microsoft.AspNetCore.Http.HttpContext httpContext, string action = default, string controller = default, object values = default, Microsoft.AspNetCore.Http.PathString? pathBase = default, Microsoft.AspNetCore.Http.FragmentString fragment = default, Microsoft.AspNetCore.Routing.LinkOptions options = default);
static member GetPathByAction : Microsoft.AspNetCore.Routing.LinkGenerator * Microsoft.AspNetCore.Http.HttpContext * string * string * obj * Nullable<Microsoft.AspNetCore.Http.PathString> * Microsoft.AspNetCore.Http.FragmentString * Microsoft.AspNetCore.Routing.LinkOptions -> string
<Extension()>
Public Function GetPathByAction (generator As LinkGenerator, httpContext As HttpContext, Optional action As String = Nothing, Optional controller As String = Nothing, Optional values As Object = Nothing, Optional pathBase As Nullable(Of PathString) = Nothing, Optional fragment As FragmentString = Nothing, Optional options As LinkOptions = Nothing) As String

Parameters

generator
LinkGenerator

The LinkGenerator.

httpContext
HttpContext

The HttpContext associated with the current request.

action
String

The action name. Used to resolve endpoints. Optional. If null is provided, the current action route value will be used.

controller
String

The controller name. Used to resolve endpoints. Optional. If null is provided, the current controller route value will be used.

values
Object

The route values. Optional. Used to resolve endpoints and expand parameters in the route template.

pathBase
Nullable<PathString>

An optional URI path base. Prepended to the path in the resulting URI. If not provided, the value of PathBase will be used.

fragment
FragmentString

A URI fragment. Optional. Appended to the resulting URI.

options
LinkOptions

An optional LinkOptions. Settings on provided object override the settings with matching names from RouteOptions.

Returns

A URI with an absolute path, or null if a URI cannot be created.

Applies to


Feedback

Was this page helpful?