webclient 401 转换为 c#
我在使用网络客户端时遇到一些问题。
当我尝试时:
var client = new WebClient();
client.Credentials = new NetworkCredential("intranet.homolog", "S3br@32011", "na-sebrae");
var html = client.DownloadData("http://www.intranet.sebrae.com.br/noticias/todas-as-notícias/rss.aspx?estado=");
我收到错误(401)。
该 url 返回 xml feed,当我在浏览器中访问它时,我可以正常登录。
该用户和密码是真实的。
有人有一些想法可以让我使用网络客户端访问它吗?
I'm have some problems to use webclient.
When I try it:
var client = new WebClient();
client.Credentials = new NetworkCredential("intranet.homolog", "S3br@32011", "na-sebrae");
var html = client.DownloadData("http://www.intranet.sebrae.com.br/noticias/todas-as-notícias/rss.aspx?estado=");
I get an error (401).
This url returns xml feed, and, when I access it into browser, I login normally.
This user, and password are real.
Somebody have some ideia to I access it with the webclient?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的猜测是:您误用了 NetworkCredential 构造函数。
正确的语法是
首先是用户名,然后是密码,然后是域 - 您的语法全错了。
请尝试以下操作:
Here's my guess: you're misusing the
NetworkCredential
constructorThe correct syntax is
First username, then password, then domain - you got yours all wrong.
Try the following:
我也遇到同样的错误。相同的链接在浏览器中效果更好,但为
WebClient
提供 401 异常。I too get same error. The same link work better in browser but but giving 401 exception for
WebClient
.