簡體   English   中英

通過地理編碼 API 的 Web 請求出現錯誤 407(代理身份驗證請求)

[英]Error 407 (Proxy Authentication Request) on Web Request via Geocoding API

我正在編寫一段代碼,它將接收用戶輸入的地址,並返回緯度/經度值供以后使用。 為此,我使用了地理編碼 API。 我所擁有的是:

try
{
    IGeocoder geo = new GoogleGeocoder() { };
    Address[] addresses = geo.Geocode(address.Text).ToArray();
    foreach (Address adr in addresses)
    {
        // just testing it out
        MessageBox.Show(adr.Coordinates.ToString());
    }
}
catch (Exception ex)
{
    // error treating
}

address是一個文本框,用戶可以在其中輸入地址。 但是,運行時出現 407 錯誤。

我已經閱讀了很多問題並嘗試了他們的解決方案(比如這個,或者這個),但沒有一個奏效。

關於我缺少什么的任何想法?

由於它拋出有關代理的錯誤,您可以嘗試將代理詳細信息設置為GoogleGeocoder 類

GoogleGeocoder geocoder = new GoogleGeocoder
{
    Proxy = new WebProxy
    {
        Address = new Uri("proxy url"),
        Credentials = new NetworkCredential("username", "password")
    }
};

暫無
暫無

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

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