简体   繁体   中英

ASP.NET MVC Login Route

Currently I am using ASP.NET MVC and have home/index for logged out user which appears as "/" but this has got me confused as to how I can have "/" for a logged in user?

I could modify like 127.0.0.1/home - but I want it like "/". My confusion relates to the fact that the "/" [127.0.0.1/] is bound in the routes collection to home/index.

How can I have it so that "/" is shared for login/logout ?

In your HomeController

public ActionResult Index()
{
    if (User.Identity.IsAuthenticated) return view("Logged");
    else return View("NotLogged");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM