Search code examples
c#authenticationiisformsauthentication

How to prevent download of files to unauthenticated users


I have a website into which users log in using forms authentication, with a folder path from which I do not want any unauthenticated users (those users not logged in) to download files from. How can I implement this?

Thanks,

Sachin


Solution

  • You can do this through configuration, see http://msdn.microsoft.com/en-us/library/8d82143t.aspx

    <location path="Files">
       <system.web>
         <authorization>
           <deny users="?"/>
         </authorization>
       </system.web>
    </location>