Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, i do have requirement that among all bunch of aspx pages, i need to provide access on all of those pages to both users and admins, but for a single webpage i need to provide access to only administrators who are present in database, how can i solve this?
Posted
Comments

There are several ways to prevent a page to users
1. Check the User role in Page_Load event of the page, If valid user role then serve the page other wise redirect to another page.
2.Prevent to display the menu link through XML Xpath logic.
3.Put the page in one folder and use forms authentication.
 
Share this answer
 
Comments
pavan_ kumar 22-Sep-14 5:54am    
can u please tell me how to implement
Thanks7872 22-Sep-14 6:07am    
What do you mean by "How to implement"? No one will be going to code for you. He gave you hint on how to proceed. Rest is your responsibility.
For this there are many approach :-

First one is that : you can give Role Column in your login Table Which shows the role.
And Store Role is session["Role"].
Give Two conditions on those page which is only for administrator.
Condition is on Page Load.

if(Session["Id"] == "abcd" && session["Role"] == "admin")
{
do what ever you want
}
else
something.....

Second Approach : If their is only single Admin. Then you can put their id hard coded in Page load on this page which is only for admin

if(Session["Id"] == "AD1234" )
{
}

and many approaches to solve this problem. You can try ...
 
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