Lost
Lost

Reputation: 13565

Call an ActionMethod from one controller to another with HttpPost

I am looking at different ways to call an ActionMethod from Controller and I know that you can call an ActionMethod from One controller to another. However, we can see that some of the actionmethods are decorated with [HttpPost] and if we are calling these methods from the View then Ajax call will specify explicitly that what we are calling an action-method with [HttpPost] on it.

However, If you are calling an action method from another ActionMethods return RedirectToAction(). However, I am not sure where do we specify that it is [HttpPost] in this particular case?

Upvotes: 0

Views: 787

Answers (1)

Ken
Ken

Reputation: 36

If you are using RedirectToAction(), then you're application is redirecting your browser's request to another URL. So, if you were to look at the network activity... Your initial POST will respond with a "302 Found" (assuming successful). Then, a URL is provided for a redirected request to occur. So, if you were posting to Action1, and Action1 has a RedirectToAction to Action2, you would leave the [HttpPost] annotation on Action1.

Upvotes: 1

Related Questions