I wanted to escape login page if user is already authenticated so i follow the suggestion provided by this question. Then i got this problem of too many redirect.I got this error when i tried to login for the very first time even though i logged in successfully. Apart from the first time it worked as charm.I am new to MVC . I searched all over and found some quite same scenario but they didn't work for me so here i am asking for your help . Thanks in advance .
This is my main page after user successfully logged in.(
public ActionResult Main()
This is my login controller action .
public ActionResult Login(string returnUrl)
ViewBag.ReturnUrl = returnUrl;
return RedirectToAction("Main", "Home");
I am using form authentication for login .
<compilation debug="true" targetFramework="4.6" />
<httpRuntime targetFramework="4.6" />
<forms loginUrl="~/" defaultUrl="~/Login/Login">
here is screenshot
I think the problem is that when you redirect to your home page it's taking you back to the login page because you have set the defaultUrl to be your login page.
I would suggest that you set defaultUrl to "~/Home/Main" and see if that helps. Also, you probably want loginUrl to be "~/Login/Login" or something