簡體   English   中英

HttpWebRequest.GetResponse()返回404:找不到有效的URL

[英]HttpWebRequest.GetResponse() returning 404: Not Found for a valid URL

我正在制作一個統一的應用程序,我需要下載一個文件。 我正在使用以下代碼來獲取標頭值:

    HttpWebRequest request =   (HttpWebRequest)System.Net.WebRequest.Create(remoteFile);
    request.Method = "HEAD"; 

    HttpWebResponse resp = null;

        try {
            resp = request.GetResponse() as HttpWebResponse;
      }catch (System.Exception e) { 
        Debug.LogWarning("ERROR: " + e);
        return;
      }

這段代碼適用於某些文件,但我在ge.tt上托管了一個文件,但它無法正常工作。 我給它的鏈接立即開始下載chrome。

錯誤是:

ERROR: System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result)

有誰知道為什么會這樣?

謝謝!

鏈接是https,當我將其更改為http時,它向我發送了一個身份驗證錯誤,因此我按照鏈接修復了它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM