asp.net-mvc-2

MVC 2.0 Post Form to action instead of redirect to action


I am using T4MVC to redirect to another action return RedirectToAction(MVC.MyController.MyAction());. In result it is doing get request.

Is there any way to make post request from controller. I want to keep all the same but only make post instead get. I cant find any methods for that. I found one post helper here Link but i cant pass any values i need using this post helper. I was trying to pass values through TempData but they are not coming when i using this helper. May be some one have any ideas?

The reason i want to do this because when user come from one controller to another and then if user click update or just click enter in browser address bar, page will break.

Should i use session for that reason?


Solution

  • only way of doing post is by having a form and doing submit on that form, either with a submit button or with javascript, any info you want passed to that action must be in that form and you will find everything posted in FormCollection(hope I spelled it right).