简体   繁体   中英

Deny Folder and direct link access in .NET MVC

I have the following code in the Web.config file

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

It denies access to the specified folder and sub-folders but direct link access to files is still possible. How can I fix it?

Thanks

Add this to <system.webServer>

<security>
  <requestFiltering>
    <hiddenSegments>
      <add segment="UserContent"/>
    </hiddenSegments>
  </requestFiltering>
</security>

This will prevent anyone from accessing the folder, sub-folders and static files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM