954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Asp.net Page access Control

HI,

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#.

Thanks.

sanbal
Newbie Poster
12 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

you can make access to different pages by using Session.

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

like
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.

like

Page_Load()
{

if(Session["Role"].ToString() != "Admin")
{
Response.Redirect("Login.aspx");
}
// same thing u can use for every user role
}

n4naeem
Newbie Poster
8 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

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

sanbal
Newbie Poster
12 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You