How can I use multiple ajax forms with AntiForgery validation on the same MVC3 page?

◇◆丶佛笑我妖孽 提交于 2019-12-03 21:22:29

In order to use the AntiForgeryToken multiple times, I do the following. First, at the top of my view, I add the following line:

ViewBag.__RequestVerificationToken = @Html.AntiForgeryToken().ToString();

Then, in each form where I need the token, I add the following:

@Html.Raw(ViewBag.__RequestVerificationToken)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!