Sunday 25 November 2018

The required anti-forgery form field "RequestVerificationToken" is not present Solution


應用程式中發生伺服器錯誤。 

The required anti-forgery form field "__RequestVerificationToken" is not present.

解決方式:

在View 送出的Form頁面using處下方,要加入下面字眼

@Html.AntiForgeryToken()

(Solutions)
You have [ValidateAntiForgeryToken] attribute before your action. 
You should add @Html.AntiForgeryToken() in your form.

Example:
@using(Html.BeginForm())
{
     @Html.AntiForgeryToken()
     <input name="..." type="text" /> 
}

No comments:

Post a Comment

找不到匯入的專案  請確認 <Import> 宣告中的路徑正確,而且檔案存在於磁碟上。

【Problem】  C:\inetpub\wwwroot\project\project.csproj : error  : 找不到匯入的專案 "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\W...