The anti-forgery token could not be decrypted

前端 未结 11 1199
萌比男神i
萌比男神i 2020-11-28 08:34

I have a form:

@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {
@Html.AntiForgeryToken()
@Html.ValidationSummary()...

and a

11条回答
  •  一整个雨季
    2020-11-28 09:02

    validationKey="AutoGenerate"

    This tells ASP.NET to generate a new encryption key for use in encrypting things like authentication tickets and antiforgery tokens every time the application starts up. If you received a request that used a different key (prior to a restart for instance) to encrypt items of the request (e.g. authenication cookies) that this exception can occur.

    If you move away from "AutoGenerate" and specify it (the encryption key) specifically, requests that depend on that key to be decrypted correctly and validation will work from app restart to restart. For example:

    
    

    You can read to your heart's content at MSDN page: How To: Configure MachineKey in ASP.NET

提交回复
热议问题