AntiforgeryExtensions.GetHtml(IAntiforgery, HttpContext) 方法

定义

<为防伪造令牌生成 input type=“hidden”> 元素。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ GetHtml(Microsoft::AspNetCore::Antiforgery::IAntiforgery ^ antiforgery, Microsoft::AspNetCore::Http::HttpContext ^ httpContext);
public static Microsoft.AspNetCore.Html.IHtmlContent GetHtml (this Microsoft.AspNetCore.Antiforgery.IAntiforgery antiforgery, Microsoft.AspNetCore.Http.HttpContext httpContext);
static member GetHtml : Microsoft.AspNetCore.Antiforgery.IAntiforgery * Microsoft.AspNetCore.Http.HttpContext -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function GetHtml (antiforgery As IAntiforgery, httpContext As HttpContext) As IHtmlContent

参数

antiforgery
IAntiforgery

IAntiforgery 实例。

httpContext
HttpContext

HttpContext 当前请求关联的 。

返回

包含IHtmlContent<输入类型=“hidden”元素的> 。 此元素应放在窗体>内<。

注解

此方法有一个副作用:如果没有与请求关联的有效 Cookie,则设置响应 Cookie。

适用于