Click here to Skip to main content
15,919,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
I have a website that Contains pdf files stored in folder on server and i need to set access to this files in folder only for users that logged in and belong to role i choose! thanks for helping :) :)

Explain the situation: name of folder is "files" name of a file in folder is "f.pdf" when i type this url "www.website.com/files/f.pdf" it's open pdf file that suppose open only for authenticated users?? how can i solve this problem ??
Posted

Add this code in your web.config

C#
<location path="files">
    <system.web>
      <authorization>
        <deny users="?" />
        <allow roles="RoleToAllow" />            
      </authorization>
    </system.web>
  </location>


Refer this link
Authorization in ASP.NET
 
Share this answer
 
v2
In case something else is interested to the solution of this answer, Mike Brind answered to this thread: How Can i allow users belongs to role only to access files in folder?[^].
 
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