I am new to Asp.net . i have a login page, with user role like guest, member, admin.I want to control the page access based on their role. How can we do this in asp.net and c#.


you can make access to different pages by using Session.

every user has its own role. so in database define Roles for every user.

there would be three fields ..

User name , Password and Role.

when you click on the button sign in
if the username and password matched.

put the respective role in the session variable like that.

like ....

Session["Role"] = "Admin";

now check in every page_load event of every page.



if(Session["Role"].ToString() != "Admin")
// same thing u can use for every user role

Thanks for your reply. Let me try with this and get back to you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.