Search code examples
c#asp.netwebformsasp.net-identity

ASP.NET Web Forms "Individual Accounts" not redirecting to login page for not logged in users


I looked everywhere for my specific situation and I can't find it anywhere.

I am new to ASP.NET and I recently created an ASP.NET Web Forms project with Individual Accounts ENABLED.

I know that if this option is selected it uses ASP.Net Identity but I cant find anywhere on how to make it so only logged in accounts can access the website specifically with Web Forms Selected when the project is created.

I just want it so not logged in accounts are redirected back to the log-in page.

I don't know where else to go and if any of you guys can help a newbie like me I would be grateful. Thanks!


Solution

  • Ok, here is some example.

    In your project you have one file with the name web.config.

    Add in inside in the section <system.web> --> authentication and authorization

    enter image description here

    This is a usefull link that you could need:https://www.c-sharpcorner.com/UploadFile/fa9d0d/forms-authentication-in-Asp-Net/