I have to updated asp.net webform application to using Microsoft.AspNet.Identity at this point i am stuck at two points
- How to protect folder (example admin) with Microsoft.AspNet.Identity
- How can i add roles to Microsoft.AspNet.Identity
I have spend hours looking for article or videos most of the either point to MVC or ASP.Net Core, while i want to use this in ASP.Net webform application with .Net Framework 4.8.
Any pointer or working example would be great.
I would appreciate example of also how to add role and use role in asp.net webform application.
In simple old asp.net membership we use to protect folder in web.config but i am not sure how to do same in Microsoft.AspNet.Identity as i have not used this in past.
Sangeetha SPosted Mar 3, 2025, 5:50 AM
o password protect a folder using AspNet.Identity in an ASP.NET Web Forms application, you can follow these general steps:
Set Up AspNet.Identity: Ensure you have AspNet.Identity integrated into your project. This usually involves setting up the necessary packages and configuring your identity context.
Create a Login Page: Build a login page where users can enter their credentials. Use the
UserManagerto validate user credentials.Authorize the Folder: In your folder (or the pages within it), you can check if the user is authenticated. If not, redirect them to the login page.