I use the latest MVC, with attribute routing.
When a user submits a contact form, it then redirects to a "thank you for submitting your info" view, with route foo.com/success
.
How can I configure it so that my code can redirect to that success
action as usual, but the user cannot navigate to it directly?
if you do not have a link in page, user won't access it directly.
Otherwise if user cannot access it, you cannot access it via code neither.
[HttpGet]
public ActionResult MyAction(){
//...
return RedirectToAction("Success");
}
[HttpGet]
public ActionResult Success(){
ViewBag.Result = "thank you for submitting your info";
return View();
}