How to check a user on another webpage after login ,request is originated from that user.....

Posted by Arunkumar_1492 under ASP.NET on 4/15/2013 | Points: 10 | Views : 791 | Status : [Member] | Replies : 1
i have prepare a application in vs10.
in this i validate a user on login page and user have role that is user is only able to access only their accessible page not another role's user.

e.g. a normal user not have authority to access admin page.

so,how can i do this ........
please help's urgent.....



Posted by: Santhi on: 4/16/2013 [Member] Starter | Points: 25


You can achieve like this..
I hope every page must have a master page right.
So check the condition in the master page.
You would maintain some status for the user roles.
For example: if the user is an Admin , the status might be 1
for the normal users, the status might be 2.

Maintain this role status on the database.
so that, you can easily achieve this.

Step 1: Get the userid and username in the session.
By passing this username to the database ,get the
user role status.
Now, store this status on the session .
Example:Session["UserRole"] ="1"

Step 2:
Check this on the master page.

if(Convert.ToString(Session["UserRole"]) == "1")

//give access to those pages alone.
else if(Convert.ToString(Session["UserRole"]) == "2")

//give access to those pages alone.

Step 2:

Thanks & Regards,
Santhi .V

Arunkumar_1492, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response