How to pass through the AntiForgeryToken in MVC

后端 未结 1 753
星月不相逢
星月不相逢 2021-01-24 14:02

How to pass through the AntiForgeryToken to another action? The following does of course not work:

[ValidateAntiForgeryToken]
public ActionResult CheckSelection(         


        
1条回答
  •  南笙
    南笙 (楼主)
    2021-01-24 14:20

    That is not possible. The anti-forgery token is based on both an Http Cookie and a hidden value in your Form; when doing an Action Redirect, that form value is lost and therefore the anti-forgery token cannot be validated.

    You will need to come up with a design that does not need action redirect...

    0 讨论(0)
提交回复
热议问题