Click here to Skip to main content
15,560,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all ,

I have 2 roles in my web: admin and user.And i have a functionality on my web that i want to allow only logged in user to do which is searching for example.So how can i do this ?

Thanks in advance.

One way to do this is to implement an "if" statement in your code behind to show or hide the appropriate controls based on the user's role. If you are looking to understand how to implement the roles themselves, you should check out one of these articles:
Forms Authentication and Role based Authorization: A Quicker, Simpler, and Correct Approach[^]
Authenticate User by Roles in ASP.NET[^].
There are many other articles here on code project that cover this and it would a good idea to start there.
Share this answer
Monjurul Habib 21-Jun-11 14:38pm    
nice links, my 5.

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