【问题标题】:403 Forbidden error in Public Folder when I try redirection当我尝试重定向时,公用文件夹中出现 403 禁止错误
【发布时间】:2016-10-05 21:36:52
【问题描述】:

我有 ASP.NET 网站。

我可以访问公共页面,没关系:

http://mysite/MyPublicFolder/index.htm

但是当我尝试访问该文件夹时收到 403 错误

http://mysite/MyPublicFolder/

MyPublicFolder 包含 index.htm

我要不允许用户浏览目录,只能访问文件夹中的所有页面

我们有以下错误:

403 - 禁止:访问被拒绝

您无权使用 您提供的凭据。

<location path="/MyPublicFolder">
  <system.web>
     <authorization>
        <allow users="*"/>
     </authorization>
  </system.web>
 </location>

我使用的是 IIS 7.5,Windows Server 2008 R2。

有什么建议吗?

更新web.config

注意:v1 是我的公共文件夹

<location path="v1">
    <system.web>
      <authorization configSource="Config\system.web.authorization.allow.config" />
    </system.web>

    <system.webServer>
      <defaultDocument>
        <files>
          <add value="index.htm"/>
        </files>
      </defaultDocument>
      <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
          <add wildcard="*" destination="/v1/index.htm" />
        </httpRedirect>
    </system.webServer>

  </location>

    <location path="v1/index.htm">
    <system.webServer>
      <httpRedirect enabled="false" />
    </system.webServer>
  </location>

【问题讨论】:

  • 你想让你的用户浏览你的目录吗?
  • 我要不允许用户浏览目录,只能访问文件夹中的所有页面。 MyPublicFolder 包含 index.htm

标签: asp.net path url-redirection http-status-code-403


【解决方案1】:

我首先想到的是默认文档。您是否将其设置为“index.htm”? Here 提供更多信息。

【讨论】:

    【解决方案2】:

    这听起来有点混乱。您是说您可以打开http://mysite/MyPublicFolder/index.htm,这意味着您已经可以访问此文件夹中的所有页面。我只能猜测您希望在访问文件夹时重定向到index.htm 文件。查看 IIS 管理器中的 Default Document 部分并确保 index.htm 存在。

    更新:

    您的web.config 文件中似乎有很多无用的配置。将其更改为以下内容:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <location path="v1">
        <system.web>
          <authorization configSource="Config\system.web.authorization.allow.config" />
        </system.web>
      </location>
    </configuration>
    

    现在,如果您访问 v1 文件夹,它应该会自动显示您的 index.htm 文件的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-22
      • 1970-01-01
      • 1970-01-01
      • 2018-07-28
      • 1970-01-01
      • 2020-02-17
      • 2013-03-02
      • 2020-11-15
      相关资源
      最近更新 更多