Deny users to access a folder

2019-07-30 00:57发布

问题:

I have this upload file structure link localhost:58707/uploads/interaction/5/Chrysanthemum.jpg

I want to deny all the users to access '~/uploads' directly..

So, I put this in my web.config as I see in others questions here:

  <location path="~/uploads"> //I've tried '/upload' and 'upload' too.
    <system.webServer>
      <directoryBrowse enabled="false" />
    </system.webServer>
  </location>

But it doesn't work. How can I do this?

回答1:

Check this answer ..

Deny access to 'admin' folder in web.config

Also

http://www.sitefinity.com/devnet/kb/sitefinity-3-x/how-to-restrict-the-access-to-a-given-folder-for-a-specific-role.aspx



回答2:

This solution is working for my project: Use App_Data