I have a partial view called Login.ascx that has my login boxes that I include on a number of pages throughout my site. It works fine when the information is correct but I’m trying to do validation so if the login info is incorrect, I want to redirect the user back to the view they were in before to show them the login errors. What is the correct way of saying, return to the view you came from?
Share
Sounds like instead of asking how I do this, you should be asking yourself WHY am I doing it this way. Maybe it’s a design decision rather than a technical question.
Though if you’re really going to have one controller actions for multiple login pages you can try…
Or keep the route name in TempData and just use a RedirectToRoute(TempData[‘LoginRoute’]);
Both solutions have a bad code smell though.
Note that if you’re not checking for cross-site injections that is just going to refer back to the other site. You may want to do some validation on the referring URL.