Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have user table which contain username and id as teacher,student,librarian
There is another table which keeps info of all the webpages in the project
Now I want to give access to each user for different pages and the info should be stored in database. And only those pages should be accessible for user.
Please tell me how can I code this in C#?
Posted

The easiest way is to implement Membership: http://msdn.microsoft.com/en-us/library/vstudio/yh26yfzy(v=vs.100).aspx[^] which includes role based authorisation: meaning that you don't have to do anything once you have sorted out the approvals via web.config
 
Share this answer
 
Create another Table for relation between user table and webpages table with following columns
id, userid, webpageid, accessstatus
accessstatus will be Boolean field. False means user don't have access of that page and True means have access.

If you want to give permission usertype wise then use usertype instead of userid.

In pages check in this table data with condition of userid/usertype and webpageid on page load event. If it returns accessstatus False then redirect to main page or any other page what ever you required else continue on the page.
 
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