I am current working on a MVC C# application and have a HttpPost ActionResult which adds a new role to a user. I want to use this method throughout my application.
The problem I have is once this method has run I want it to return to the previous ActionResult and as I want to reuse this method I can not set the return view to a set view. Is there a way to set the return to the previous View?
Many Thanks
Andrew
You could pass a returnUrl when invoking the POST controller action:
This way you can POST to this controller action from different parts of the application and every time you will provide the return url you want to get redirected to once it has finished processing. This is for example how the LogOn action in the default template works. You may take a look at it.