简体   繁体   English

.NET MVC中的拒绝文件夹和直接链接访问

[英]Deny Folder and direct link access in .NET MVC

I have the following code in the Web.config file 我在Web.config文件中有以下代码

<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> 将此添加到<system.webServer>

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

This will prevent anyone from accessing the folder, sub-folders and static files. 这将防止任何人访问文件夹,子文件夹和静态文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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