UrlHelperExtensions.ActionLink 方法

定義

產生動作方法的絕對 URL,其中包含要使用的指定 action 名稱、 controller 名稱、路由 valuesprotocol 使用、 hostfragment 名稱和 。 如果 protocolhost 不是, null 則會產生絕對 URL。 如需重要的安全性資訊,請參閱一節。

public static string ActionLink (this Microsoft.AspNetCore.Mvc.IUrlHelper helper, string action = default, string controller = default, object values = default, string protocol = default, string host = default, string fragment = default);
public static string? ActionLink (this Microsoft.AspNetCore.Mvc.IUrlHelper helper, string? action = default, string? controller = default, object? values = default, string? protocol = default, string? host = default, string? fragment = default);
static member ActionLink : Microsoft.AspNetCore.Mvc.IUrlHelper * string * string * obj * string * string * string -> string
<Extension()>
Public Function ActionLink (helper As IUrlHelper, Optional action As String = Nothing, Optional controller As String = Nothing, Optional values As Object = Nothing, Optional protocol As String = Nothing, Optional host As String = Nothing, Optional fragment As String = Nothing) As String

參數

action
String

動作方法的名稱。 當 為 時 null ,預設為目前的執行動作。

controller
String

控制器的名稱。 當 為 時 null ,預設為目前的執行控制器。

values
Object

包含路由值的物件。

protocol
String

URL 的通訊協定,例如 "http" 或 "https"。

host
String

URL 的主機名稱。

fragment
String

URL 的片段。

傳回

產生的 URL。

備註

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

適用於