Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I don't let some users who are not administrators to access on some files in a folder (eg jpg image file format or zip files) I want to limit the none administrators users by entering the address directly in the Address bar to access my files.
However, users types saves in their own session.
Posted

Implement Membership : http://msdn.microsoft.com/en-us/library/vstudio/yh26yfzy(v=vs.100).aspx[^] - you don't need to use the standard DB and controls, you can add your own via a custom MembershipProvider - once you do that, you can set a web.config file in each folder which allows you to define who is allowed access to the files, and IIS will enforce it for you - so a non-admin can set a path in the address bar and IIS will just issue an Unauthorised Access exception instead of returning the page or file.
 
Share this answer
 
I used this for login:
C#
FormsAuthentication.SetAuthCookie("admin", false);


and used this web.config file for this folder:
XML
<pre lang="xml"><?xml version="1.0"?>

<configuration>
  <appSettings/>
  <connectionStrings/>
  <system.web>
    <authorization>
      <allow users="admin"/>
      <deny users="*"/>
    </authorization>
  </system.web>
</configuration>


But it only restricts access to *.aspx files
 
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