Im trying to redirect to another action in the same controller which is decorated with
ValidateAntiForgeryToken
but since im not passing __RequestVerificationToken token,So it throws exception
ErrorMessage:A required anti-forgery token was not supplied or was invalid. Why im using ValidateAntiForgeryToken as attribute for action because, FXCop raises warning whenever i run the FXCOP to decorate with ValidateAntiForgeryToken.
Can u please little bit clear on this. Since my FormCollection has token key in inital request, do u want me add to request form collection once again b4 Redirectaction calling
i think you need to check why the second method is having that attribute? is that action is directly called from any page using any post operation?
RedirectToAction is httpget method so the vaidateantiforgery is not requried.
please try to create another common action method from the current methods with only code required to reuse and then you can access that method from both action methods
mahens
Member
43 Points
118 Posts
RedirectToAction with ValidateAntiForgeryToken error
Jul 28, 2012 07:12 PM|LINK
Hi,
Im trying to redirect to another action in the same controller which is decorated with ValidateAntiForgeryToken
but since im not passing __RequestVerificationToken token,So it throws exception
ErrorMessage:A required anti-forgery token was not supplied or was invalid. Why im using ValidateAntiForgeryToken as attribute for action because, FXCop raises warning whenever i run the FXCOP to decorate with ValidateAntiForgeryToken.
-Mahens
alvingeorge
Participant
925 Points
203 Posts
Re: RedirectToAction with ValidateAntiForgeryToken error
Jul 28, 2012 07:19 PM|LINK
try to add a antiforgerytoken before you redirectoaction.
add to Request.Form
mahens
Member
43 Points
118 Posts
Re: RedirectToAction with ValidateAntiForgeryToken error
Jul 29, 2012 12:23 PM|LINK
Hi George,
Can u please little bit clear on this. Since my FormCollection has token key in inital request, do u want me add to request form collection once again b4 Redirectaction calling
alvingeorge
Participant
925 Points
203 Posts
Re: RedirectToAction with ValidateAntiForgeryToken error
Jul 29, 2012 01:39 PM|LINK
i think you need to check why the second method is having that attribute? is that action is directly called from any page using any post operation?
RedirectToAction is httpget method so the vaidateantiforgery is not requried.
please try to create another common action method from the current methods with only code required to reuse and then you can access that method from both action methods