【问题标题】:IIS 8.0 access rights to files in a forbidden folderIIS 8.0 对禁止文件夹中文件的访问权限
【发布时间】:2015-02-17 01:12:49
【问题描述】:

我有一个 Asp.net 网站,其中有一个文件夹 /Images。 我设置了我的 web.config 以拒绝匿名用户的访问:如果匿名用户尝试访问 MyWebsite/Images : Erreur HTTP 403.14 - Forbidden ,所以可以这样做。

但是当他们用文件名编写完整的 Url 时: MyWebsite/Images/pict.png ,他们可以打开文件!

我已经在我的 web.config 中尝试过这个,但不起作用...:

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

我有这个认证模式:

<authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/"/>
    </authentication>

【问题讨论】:

    标签: authentication iis rights


    【解决方案1】:

    默认情况下,只有托管代码会受到 web.config 身份验证设置的影响,例如 aspx 和 ashx 页面。如果您想将这些设置应用于非托管代码,例如图像、pdf 文件或其他 html 页面,您可以添加以下内容:

    <configuration>
        ...
        <system.webServer>
            <modules runAllManagedModulesForAllRequests="true">
            ...
            </modules>
        </system.webServer>
    </configuration
    

    【讨论】:

      猜你喜欢
      • 2012-07-23
      • 1970-01-01
      • 2020-07-30
      • 2014-10-14
      • 1970-01-01
      • 2013-07-02
      • 2012-03-23
      • 2017-08-29
      • 2019-02-14
      相关资源
      最近更新 更多