Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
Hello, I want to do user-based page authorization with asp.net web forms. What I want to do is to take the role of the user while logging in from the users table in the database and control which pages he can access there, for example, let the admin role access all pages, but the user role can only access profile.aspx, add. aspx, and when the unauthorized user wants to access other pages, it is directed to the authorized.aspx page. I would like you to show me all the adjustments I need to make in this regard, thank you.


What I have tried:

I tried a lot with global.asax and web.config, but I was not successful.
Posted
Comments
OriginalGriff 9-Apr-24 4:37am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?

That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project! Give us relevant code fragments, tell us what you tried and what happened when you did.

Use the "Improve question" widget to edit your question and provide better information.
Richard Deeming 9-Apr-24 6:35am    
Don't try to roll your own authentication system. Start with ASP.NET Identity[^] (or the older ASP.NET Membership[^]) and use the tools that are built-in to the system.

If you get stuck, then you need to ask a specific question, including the full details of what you have tried, the relevant parts of your code and configuration, the full details of any exceptions, and explain precisely where you are stuck.

1 solution

You probably want to start by reading and implementing authentication using Use ASP.NET forms-based authentication - ASP.NET | Microsoft Learn[^].
To control access to web pages, and folders of pages, use Control authorization permissions in ASP.NET - ASP.NET | Microsoft Learn[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900