tags:

views:

61

answers:

2

I have an action that resets a user's password. In that same action after the password is reset I want to login the user. I wanted to just use a "RedirectToAction" and send the username and password to my SignIn action. Since I have logic in that action that handles errors and what not.

So I need to send the AntiForgeryToken value to the SignIn action also.

+1  A: 

There isn't a need to do this and I don't think it would be a good idea anyway as you'd be passing the password back to the browser as part of the response. Just use FormsAuthentication to create the auth cookie and send it back with the response.

tvanfosson
+1  A: 

The AntiForgeryToken is only valid for POST requests (GET requests are supposed to be idempotent... that is, not change state on the server). RedirectToAction does an HTTP/302 redirect, which is results in a GET request. Therefor, an AntiForgeryToken would make no sense for RedirectToAction.

I would reconsider what it is you are trying to do.

Remember, actions are just public methods on the controller, so you should be able to call one (and return its result) from any other action.

Will Green
I didn't know RedirectToAction was a GET request. I guess I'll just use the FormsAuthentication.
Donny V.