Hey all!
I have an action which I need to post forward onto another action if it meets certain conditions, but I am unable to preserve the form data when passing through to the next action.
The receiving action accepts a FormCollection, which the sending action
Currently, I am doing a return RedirectToAction("action","controller", form). And I can determine that the form variable has keys before it redirects (form.HasKeys() = true).
When the action is hit however, the FormCollection is empty (form.HasKeys() = false).
Any ideas? Is there a 'PostToAction' method that I am missing?
FYI: I am using ASP.NET MVC Beta. Many thanks!
-
I would refactor the two controllers and put the common code into a helper or into a common base class. That way the actions in the two controllers can delegate to the common code.
-
When RedirectToAction is called it will make an HTTP redirection and it will make a GET to the other action URL. If you need to reuse the code from another controller I'd do what ewalshe suggest, move the common to a BaseController or a business service and make both actions delegate to it.
This links may help:
- ASP.NET MVC Tip #6 – Call RedirectToAction after Submitting a Form
- How to RedirectToAction in ASP.NET MVC (Preview 4) without losing request data
Dan Atkinson : Eduardo, thankyou for the linkage! It helped looking at Stephen Walther's example.
0 comments:
Post a Comment