AntiforgeryExtensions.GetHtml(IAntiforgery, HttpContext) Method

Definition

Generates an <input type="hidden"> element for an antiforgery token.

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

Parameters

antiforgery
IAntiforgery

The IAntiforgery instance.

httpContext
HttpContext

The HttpContext associated with the current request.

Returns

A IHtmlContent containing an <input type="hidden"> element. This element should be put inside a <form>.

Remarks

This method has a side effect: A response cookie is set if there is no valid cookie associated with the request.

Applies to