AntiForgery.GetHtml 方法

定義

多載

GetHtml()

將驗證語彙基元加入至表單,以協助防範要求偽造。

GetHtml(HttpContextBase, String, String, String)
已淘汰.

將驗證語彙基元新增至表單,以協助防範要求偽造,並讓呼叫者指定驗證詳細資料。

GetHtml()

將驗證語彙基元加入至表單,以協助防範要求偽造。

public static System.Web.HtmlString GetHtml ();
static member GetHtml : unit -> System.Web.HtmlString
Public Shared Function GetHtml () As HtmlString

傳回

傳回字串,這個字串包含隱藏 HTML 欄位中加密的語彙基元值。

例外狀況

目前的 HttpContext 物件為 Null。

適用於

GetHtml(HttpContextBase, String, String, String)

警告

This method is deprecated. Use the GetHtml() method instead. To specify a custom domain for the generated cookie, use the <httpCookies> configuration element. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.

將驗證語彙基元新增至表單,以協助防範要求偽造,並讓呼叫者指定驗證詳細資料。

[System.Obsolete("This method is deprecated. Use the GetHtml() method instead. To specify a custom domain for the generated cookie, use the <httpCookies> configuration element. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.", true)]
public static System.Web.HtmlString GetHtml (System.Web.HttpContextBase httpContext, string salt, string domain, string path);
static member GetHtml : System.Web.HttpContextBase * string * string * string -> System.Web.HtmlString
Public Shared Function GetHtml (httpContext As HttpContextBase, salt As String, domain As String, path As String) As HtmlString

參數

httpContext
HttpContextBase

要求的 HTTP 內容資料。

salt
String

隨機字元的選擇性字串, (例如 Z*7g1&p4) ,用來將複雜度新增至加密,以取得額外的安全性。 預設值是 null。

domain
String

從中送出要求的 Web 應用程式網域。

path
String

從中送出要求之 Web 應用程式的虛擬根目錄路徑。

傳回

傳回隱藏 HTML 欄位中的加密語彙基元值。

屬性

例外狀況

httpContext 為 null。

適用於