@using Microsoft.AspNetCore.Antiforgery
@inject Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor
@inject IAntiforgery antiforgery
@{
    var token = antiforgery.GetAndStoreTokens(httpContextAccessor.HttpContext).RequestToken;
}
<input type="hidden" value="@token" name="__RequestVerificationToken" id="__RequestVerificationToken" />