应用程序更新程序 - 不断收到 401 未经授权的错误

发布于 2024-10-19 12:07:19 字数 836 浏览 4 评论 0原文

我正在测试 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乖乖兔^ω^ 2024-10-26 12:07:19

您是否尝试过通过 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.

简美 2024-10-26 12:07:19

您的计算机是否通过身份验证 Web 代理连接到 Internet?如果是,.NET 将不会与代理通信,除非应用程序配置文件包含如下内容:

<system.net>
  <defaultProxy useDefaultCredentials="true"/>
</system.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:

<system.net>
  <defaultProxy useDefaultCredentials="true"/>
</system.net>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文