ControllerLinkGeneratorExtensions.GetUriByAction 方法

定義

多載

GetUriByAction(LinkGenerator, String, String, Object, String, HostString, PathString, FragmentString, LinkOptions)

根據提供的值產生絕對 URI。

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

根據提供的值產生絕對 URI。

GetUriByAction(LinkGenerator, String, String, Object, String, HostString, PathString, FragmentString, LinkOptions)

根據提供的值產生絕對 URI。

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

參數

action
String

動作名稱。 用來解析端點。

controller
String

控制器名稱。 用來解析端點。

values
Object

路徑值。 可能是 Null。 用來解析端點,並在路由範本中展開參數。

scheme
String

套用至結果 URI 的 URI 配置。

host
HostString

套用至結果 URI 的 URI 主機/授權單位。

pathBase
PathString

選擇性 URI 路徑基底。 在產生的 URI 中前面加上路徑。

fragment
FragmentString

URI 片段。 選擇性。 附加至產生的 URI。

options
LinkOptions

選擇性 LinkOptions。 所提供物件的設定會覆寫具有相符名稱的 RouteOptions 設定。

傳回

絕對 URI,如果無法建立 URI,則 null 為 。

備註

的值 host 應該是受信任的值。 除非已驗證標頭,否則 Host 依賴目前要求的值可允許不受信任的輸入影響產生的 URI。 如需如何在部署環境中正確驗證 Host 標頭的指示,請參閱部署檔。

適用於

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

根據提供的值產生絕對 URI。

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

參數

httpContext
HttpContext

HttpContext與目前要求相關聯的 。

action
String

動作名稱。 用來解析端點。 選擇性。 如果 null 提供 ,則會使用目前的動作路由值。

controller
String

控制器名稱。 用來解析端點。 選擇性。 如果 null 提供 ,則會使用目前的控制器路由值。

values
Object

路徑值。 選擇性。 用來解析端點,並在路由範本中展開參數。

scheme
String

套用至結果 URI 的 URI 配置。 選擇性。 如果未提供,則會使用 的值 Scheme

host
Nullable<HostString>

套用至結果 URI 的 URI 主機/授權單位。 選擇性。 如果未提供,則會使用 值 Host

pathBase
Nullable<PathString>

選擇性 URI 路徑基底。 在產生的 URI 中前面加上路徑。 如果未提供,則會使用 的值 PathBase

fragment
FragmentString

URI 片段。 選擇性。 附加至產生的 URI。

options
LinkOptions

選擇性 LinkOptions。 所提供物件的設定會覆寫具有相符名稱的 RouteOptions 設定。

傳回

絕對 URI,如果無法建立 URI,則 null 為 。

備註

的值 host 應該是受信任的值。 除非已驗證標頭,否則 Host 依賴目前要求的值可允許不受信任的輸入影響產生的 URI。 如需如何在部署環境中正確驗證 Host 標頭的指示,請參閱部署檔。

適用於