[英]Error 407 (Proxy Authentication Request) on Web Request via Geocoding API
I'm writing a piece of code that will take in addresses input by the user, and return the latitude/longitude values for later use.我正在编写一段代码,它将接收用户输入的地址,并返回纬度/经度值供以后使用。 For this, I'm using the Geocoding API.
为此,我使用了地理编码 API。 What I have is:
我所拥有的是:
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
is a Textbox where the user types in the addresses. address
是一个文本框,用户可以在其中输入地址。 However, I get the 407 Error when I run it.但是,运行时出现 407 错误。
I've read many questions and tried their solutions (like this one , or this one ), but none have worked.我已经阅读了很多问题并尝试了他们的解决方案(比如这个,或者这个),但没有一个奏效。
Any ideas on what I'm missing?关于我缺少什么的任何想法?
Since it is throwing an error regarding proxy, you can try setting your proxy details to GoogleGeocoder class .由于它抛出有关代理的错误,您可以尝试将代理详细信息设置为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.