2

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?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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);

3 Comments

I know, but I want to redirect user if only he manually changes url... If user clicks Post button, it's ok))))
Do you mean you want to redirect user to the previous page if he is trying to manually change the url to the success page?
No, i mean that I want to redirect user to previous page if he writes in browser's url .../Success and clicks enter))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.