ASP.Net MVC: How unauthorize access redirect user to login page
-
suppose i am developing a site with ASP.Net MVC core. i have created a empty project where i add two controller. one is Home and login controller. Home controller's index action is not protected by Authorized attribute but Home controller's product action is protected. when user try to access product action then user should be redirected to login page if not signed in. so tell me how to setup project in classic mvc or mvc core where i will mention that user should be redirected to login page if user is not signed in. i will not use identity rather i will check user credentials from db using ado.net. please guide me step wise that what i need to follow. Thanks
-
suppose i am developing a site with ASP.Net MVC core. i have created a empty project where i add two controller. one is Home and login controller. Home controller's index action is not protected by Authorized attribute but Home controller's product action is protected. when user try to access product action then user should be redirected to login page if not signed in. so tell me how to setup project in classic mvc or mvc core where i will mention that user should be redirected to login page if user is not signed in. i will not use identity rather i will check user credentials from db using ado.net. please guide me step wise that what i need to follow. Thanks
Introduction to authorization in ASP.NET Core | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Introduction to authorization in ASP.NET Core | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Sir, my question was bit different. i am trying to know how asp.net mvc engine understand now user need to redirect to login page? if login controller name would be different then how asp.net mvc understand it ? where this binding done in default project when we create a default project from IDE? i believe there must be a place where we mention that login page should come if user is not signed in when access any protected resource. please share knowledge if you know. thanks
-
Sir, my question was bit different. i am trying to know how asp.net mvc engine understand now user need to redirect to login page? if login controller name would be different then how asp.net mvc understand it ? where this binding done in default project when we create a default project from IDE? i believe there must be a place where we mention that login page should come if user is not signed in when access any protected resource. please share knowledge if you know. thanks
Overview of ASP.NET Core Authentication | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer