AntiForgery.GetHtml 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
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。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈