Hi
If user is not authenticated Login Page should Open but it is not opening. I need if User is not Login then Login View should be displayed.How this can be done
Home Controller
public class HomeController : Controller
{
[AllowAnonymous]
public ActionResult Index()
{
return View();
}
public ActionResult Login()
{
return PartialView("_Login");
}
[HttpPost]
[Authorize]
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index");
}
}
Home Index - Blank Page
Route.Config
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Web.Config
Thanks

Sachin SinghRank #66 · 26.2K reputationPosted Jun 22, 2021, 12:07 PM EDT
Satya KarkiRank #78 · 24.6K reputationPosted Jun 22, 2021, 12:49 PM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 22, 2021, 1:28 PM EDT
Satya KarkiRank #78 · 24.6K reputationPosted Jun 22, 2021, 10:26 PM EDT
Arnab MukherjeeRank #879 · 2.5K reputationPosted Jun 22, 2021, 12:07 PM EDT
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 22, 2021, 12:18 PM EDT
Hi Sachin
Is this to be done on each Controller
[Authorize(Roles="Admin,Editor")]
Is it possible that it can Centralised at one location.
Thanks
Rijwan AnsariRank #82 · 24.2K reputationPosted Jun 22, 2021, 1:43 PM EDT
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 22, 2021, 9:36 PM EDT
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 23, 2021, 4:53 AM EDT
LogOn
Sachin SinghRank #66 · 26.2K reputationPosted Jun 23, 2021, 5:02 AM EDT