WebClient.UploadData 错误:(401) 未经授权
我收到此错误...令我困惑的是,我没有为我调用的页面启用任何类型的安全性...
WebClient myWebClient = new WebClient();
myWebClient.UploadData(myUrl,"POST", myByteArray);
当我直接访问该页面(在 ie 上)时,它工作正常,使用 WebClient 它不起作用。
任何人都知道可能出了什么问题吗?
I'm getting this error... What is puzzling me is the fact that i do not have any type of security enabled for the page i'm invoking...
WebClient myWebClient = new WebClient();
myWebClient.UploadData(myUrl,"POST", myByteArray);
When i access directly to the page ( on ie ) it works fine, with the WebClient it's not working.
Anyone has a clue on what can be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IE 支持集成安全性,它将使用您当前的登录凭据作为用户名和密码,因此您无需手动输入。
如果您使用的是 IE,请使用 Firefox,查看是否提示您输入用户名和密码。 或者,在 IE 中,您可以转到“工具”、“选项”、“高级”,然后取消选中“集成 Windows 身份验证”。
最有可能的是,您必须将 Web 应用程序配置为支持匿名访问,或者必须在 WebClient 中实现安全性。
IE supports integrated security, which will use your current login credentials as the username and password, so you don't have to manually enter it.
If you are using IE, use Firefox and see if you are prompted for a username and password. Or, in IE, you can go to Tools, Options, Advanced, and uncheck Integrated Windows Authentication.
Most likely, you'll have to configure the web application to support anonymous access, or you'll have to implement security in your WebClient.
如果您正在努力了解其真相,Fiddler 可能会提供一些帮助。 您必须手动编辑代码才能通过 Fiddler 代理,但完成后您可以将 IE 结果与代码进行比较。
If you are struggling to get to the bottom of it Fiddler might shed some light. You will have to manually edit your code to go through the Fiddler proxy, but once that's done you can compare the IE result to the code one.