应用程序更新程序 - 不断收到 401 未经授权的错误
我正在测试 .Net 应用程序更新程序组件,如下所述 更新程序组件
我遇到一个问题,当客户端尝试访问 update.xml 文件时出现 401 Unathorized 访问错误。
当我通过网络浏览器访问该网址时,可以看到 update.xml 文件。有什么想法我做错了吗?
“服务器”部分仅位于本地主机上。
编辑
//Retrieve the File
HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
Request.Headers.Add("Translate: f");
Request.Credentials = CredentialCache.DefaultCredentials;
//Set up the last modfied time header
if (File.Exists(filePath))
Request.IfModifiedSince = LastModFromDisk(filePath);
try
{
Response = (HttpWebResponse)Request.GetResponse();// this is where error is being thrown.
}
亲切的问候
阿什
Im testing out the .Net application updater component as decribed here Updater component
Im getting an issue that when the client tries to access the update.xml file I am getting a 401 Unathorized access error.
I can see the update.xml file when I go to the url through the web browser. Any ideas what Im doing wrong?
The "server" part is just on local host.
Edit
//Retrieve the File
HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
Request.Headers.Add("Translate: f");
Request.Credentials = CredentialCache.DefaultCredentials;
//Set up the last modfied time header
if (File.Exists(filePath))
Request.IfModifiedSince = LastModFromDisk(filePath);
try
{
Response = (HttpWebResponse)Request.GetResponse();// this is where error is being thrown.
}
Kind Regards
Ash
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过通过 fiddler 运行您的 uri? - http://www.fiddler2.com/fiddler2/
使用此工具,您可以查看请求并响应,并可能找出导致问题的原因,而不仅仅是 401 错误。
Have you tried running your uri through fiddler? - http://www.fiddler2.com/fiddler2/
Using this tool you can see the request and response, and potentially work out what is causing the issue more than just a 401 error.
您的计算机是否通过身份验证 Web 代理连接到 Internet?如果是,.NET 将不会与代理通信,除非应用程序配置文件包含如下内容:
Is your computer connecting to the Internet via an authenticating web proxy? If it is, .NET won't talk to the proxy unless the application configuration file contains a bit like this: