Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi dear friends;

I need some code or method for enhancements page security

for example dll ,security reference in asp.net and scripts

And what utilize their code

Thank you
Posted
Updated 7-Sep-11 3:18am
v2

You can use the built in authorisation functionality of ASP.Net

http://msdn.microsoft.com/en-us/library/ff649100.aspx[^]

For example, by adding the following to your web.config you would deny all users that are not authenticated from your site content

XML
<authorization>
    <deny users="?"/>
</authorization>


Then you would need to consider how the user is going to authenticate. Will you use Forms Authentication[^] or Windows Authentication[^] (for something like an Intranet application)?

You can add additional web.config files to particular folders within your application directory structure. For example, say I have a section of the site that is for 'Administrators' only, I'd add a folder called Admin (or whatever) and put all my pages in there.

Then, I'd add a web.config to the Admin folder with the following...

XML
<configuration>
    <system.web>
        <authorization>
          <allow roles="Administrator" />
          <deny users="*" />
        </authorization>
    </system.web>
</configuration>


Now, anyone trying to access this folder will have their role membership interogated and only members of the Administrators role will be allowed to view the contents. You can handle any 'Not authorised' response with a redirect.

Have a read up on Security Basics[^]
 
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