【问题标题】:IIS - 403 Forbidden: Access is denied when accessing a folder published through IIS 7.0IIS - 403 Forbidden:访问通过 IIS 7.0 发布的文件夹时访问被拒绝
【发布时间】:2017-07-03 15:06:05
【问题描述】:

我们通过 IIS 7.0 发布了一个文件夹,如下所示,并在其中放入了一些文件

https://www.example.net/mydocs

如果我们通过浏览器访问以下文件,我们可以看到它

https://www.example.net/mydocs/client.xml
https://www.example.net/mydocs/log.jpg

等等。

现在我们需要编写一个pgm来下载和上传文件到这个文件夹,我们编码如下

WebClient webClient = new WebClient();
            string webAddress = null;
            try
            {
                webAddress = @"https://www.example.net/mydocs";
                webClient.UseDefaultCredentials = true;
                webClient.Credentials = CredentialCache.DefaultCredentials;

                WebRequest serverRequest = WebRequest.Create(webAddress);
                WebResponse serverResponse;
                serverResponse = serverRequest.GetResponse();
                serverResponse.Close();

                webClient.UploadFile(webAddress + @"1.xml", "PUT", @"C:\d\1.xml");
                webClient.Dispose();
                webClient = null;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }

但它在serverResponse = serverRequest.GetResponse(); 处抛出错误

错误是远程服务器返回错误:(403) Forbidden。

如果我们尝试访问

https://www.example.net/mydocs

通过浏览器我们得到了错误

403 - 禁止:访问被拒绝。您无权查看 此目录或页面使用您提供的凭据。什么时候 访问通过iis发布的文件夹

【问题讨论】:

  • 您需要允许从 IIS 进行目录浏览。

标签: c# https iis-7


【解决方案1】:

您需要允许从 IIS 浏览目录。按照以下步骤允许目录浏览。

  • 打开IIS
  • 从左窗格中选择您的网站。
  • 在右窗格/中心窗格中双击 Directory Browsing
  • 在右窗格中的Actions 下单击Enable

【讨论】:

  • 遵循了以下所有步骤,但对我不起作用。
【解决方案2】:

根据我的经验,它最终缺少安装的 Windows 功能。

我无法准确指出缺少哪些功能,因为我厌倦了它并安装了大部分功能,但这肯定解决了我的问题(并且启用目录浏览并没有)。

【讨论】:

    【解决方案3】:

    您需要在 IIS 中启用目录浏览,否则您只能通过提供文件的完整路径来访问文件。 Refer this link will show how

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-06
      • 1970-01-01
      相关资源
      最近更新 更多