Reputation: 15190
I want to access page with Success message only, when user clicks to button...
By changing url, such as .../Success
I want my site redirect user to previous page.
How can I do this via ASP.NET MVC 3?
Upvotes: 2
Views: 2536
Reputation: 9627
A quick way of doing that is to set a session containing a random number in the action which is redirecting, also pass the random number as a parameter to the other action.
Inside the other action(redirected one), compare the value of the session with the parameter of the action. If values are equal, the user is getting there by pressing button, otherwise, the user gets there by changing the URL. Hope it helps.
Upvotes: 3
Reputation: 23788
You can redirect to the specific action using:
RedirectToAction(string actionName);
If the action belongs to another controller, you can use this overload:
RedirectToAction(string actionName, string controllerName);
Upvotes: 1