Reputation: 103
I have some asp.net pages , and I want to deny them to be accessed by direct link . So I need to make a page to by accessed only by administrators and a page that will be accesed by logged users.
How can I do that? can someone explain or show a good example?
Thank you
Upvotes: 2
Views: 565
Reputation: 14460
You can create a folder with pages that needs to be accessed by set of users. Inside the folder you can create web.config with restriction.
eg.<configuration>
<system.web>
<authorization>
<deny users="user1,user2" />
<allow users="*" />
</authorization>
</system.web>
</configuration>
You can find more about ASP.NET Security
Update
On successful login you can add the users to a specific role.
eg. you assigned to the role users
then you can modify the web.config
<authorization>
<allow roles="users" />
<deny users="*" />
</authorization>
Upvotes: 1