Hi
How the below code works
<authentication mode="Forms"> <forms loginUrl="~/Home/Login" timeout="30" /> </authentication>
Main Layout File
<!DOCTYPE html> @{ if (!User.Identity.IsAuthenticated) { Context.Response.Redirect(Url.Action("Login", "Home")); } }
Thanks
ramco1917 says: if (!User.Identity.IsAuthenticated) { Context.Response.Redirect(Url.Action("Login", "Home")); } }
if (!User.Identity.IsAuthenticated) { Context.Response.Redirect(Url.Action("Login", "Home")); } }
It will check if the user is Authenticated or not.
If not Authenticated then redirect to the Login Action of Home Controller.
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.