gpt4 book ai didi

c# - IIS - 403 禁止 : Access is denied when accessing a folder published through IIS 7. 0

转载 作者:行者123 更新时间:2023-12-02 10:33:15 25 4
gpt4 key购买 nike

我们通过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();

处抛出错误

The error is The remote server returned an error: (403) Forbidden.

此外,如果我们尝试访问

https://www.example.net/mydocs

通过浏览器我们收到错误

403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied. when accessing the folder published through iis

最佳答案

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

  • 打开 IIS
  • 从左侧 Pane 中选择您的网站。
  • 在右 Pane /中央 Pane 中双击目录浏览
  • 在右 Pane 中的操作下点击启用

关于c# - IIS - 403 禁止 : Access is denied when accessing a folder published through IIS 7. 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42241168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com