Reputation: 33
I have a form on all my pages that allows the user to select their language. After this action completes I change the current language for that user then I need to make sure I redirect to the same action they were on previously.
I am not sure what the best approach is to do this in asp.net mvc. One approach is that on every page I save the controller and action as hidden variables in the language form.
The other would to save the last controller and action into tempdata and then referencing it in the action that sets the current language.
Any thoughts on which approach or another that is best for this scenario?
Upvotes: 1
Views: 1789
Reputation: 1
You can also refer the demo available at http://karticles.blogspot.com/2009/12/aspnet-mvc-pattern-var-controllersview.html
Upvotes: 0
Reputation: 75982
The request URL of the page the forms lives on has all the necessary information about the Controller and the Action. So, if you add it as a returnurl
(or simply ru
) parameter to the form, you can redirect from the POST action to that URL instead of trying to find the right Controller and Action.
Upvotes: 1