繁体   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