相关疑难解决方法(0)

System.Net.WebClient不适用于Windows身份验证

我试图在WinForms应用程序中使用System.Net.WebClient将文件上传到具有Windows身份验证的IIS6服务器,因为它只是"身份验证"方法.

WebClient myWebClient = new WebClient();
myWebClient.Credentials = new System.Net.NetworkCredential(@"boxname\peter", "mypassword"); 
byte[] responseArray = myWebClient.UploadFile("http://localhost/upload.aspx", fileName);
Run Code Online (Sandbox Code Playgroud)

我得到一个'远程服务器返回错误:(401)未授权',实际上它是401.2

客户端和IIS都在同一台Windows Server 2003 Dev计算机上.

当我尝试在Firefox中打开页面并输入与代码中相同的正确凭据时,页面出现.但是,当使用IE8时,我得到相同的401.2错误.

试过Chrome和Opera,他们都工作.

我在IE Internet选项中启用了"启用集成Windows身份验证".

安全事件日志具有失败审核:

Logon Failure:
    Reason:     An error occurred during logon
    User Name:  peter
    Domain:     boxname
    Logon Type: 3
    Logon Process:  ÈùÄ
    Authentication Package: NTLM
    Workstation Name:   boxname
    Status code:    0xC000006D
    Substatus code: 0x0
    Caller User Name:   -
    Caller Domain:  -
    Caller Logon ID:    -
    Caller Process ID:  -
    Transited Services: -
    Source Network Address: 127.0.0.1
    Source …
Run Code Online (Sandbox Code Playgroud)

iis ntlm webclient

12
推荐指数
1
解决办法
2万
查看次数

PowerShell通过凭据发出Web请求

我正在尝试访问具有Windows安全性的网站:在此处输入图片说明

所以我引用了这篇文章并编写了以下代码:

$web = New-Object Net.WebClient
$web.Credentials = new-object System.Net.NetworkCredential($username, $password, $domain)
$content = $web.DownloadString("https://my.url")
Run Code Online (Sandbox Code Playgroud)

但是在添加凭据之前,我仍然遇到相同的错误:"The remote server returned an error: (401) Unauthorized."我随后引用了此文章,但是在这种情况下,我认为基本身份验证不适用。我已经多次验证了用户名,密码和域。是否存在其他常用的通过身份验证发出Web请求的解决方案?

authentication powershell webclient

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

webclient ×2

authentication ×1

iis ×1

ntlm ×1

powershell ×1