Proxy Server Problem: Ok, I figured out what is causing the issue. We have a proxy server here so I need to pass either the requesting AUTH_USER to the proxy or the configured identity user (Service Account) to tell the Proxy that the request is ok. How
can I do this in C#?
When I run the tool on my Production box, I get this when it checks the IP vs the IP GEO Database.
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did
not properly respond after a period of time, or established connection failed because connected host
has failed to respond 162.217.175.236:80 at System.Net.Sockets.Socket.DoConnect(EndPoint
endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal
(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state,
IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at
System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at
System.Net.WebClient.DownloadString(Uri address) at FetchGeoIPData_IPAddress.btnGetGeoIPData_Click
(Object sender, EventArgs e) in xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\FetchGeoIPData_IPAddress.aspx.cs:line 75
I have been trying different iterations of setting a proxy but I cannot seem to figure it out.
My error:
System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required. at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at FetchGeoIPData_IPAddress.btnGetGeoIPData_Click(Object
sender, EventArgs e) in c:\inetpub\wwwroot\FetchGeoIPData_IPAddress.aspx.cs:line 78
Code:
case System.Net.Sockets.AddressFamily.InterNetwork:
url = string.Format("http://api.ipinfodb.com/v3/ip-city/?key={0}&ip={1}&format=json", APIKey, item);
using (WebClient client = new WebClient())
{
client.Headers["User-Agent"] = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)";
WebProxy myProxy = new WebProxy("http://xxxxxxxxxxxxxxxxxxxxx:80");
myProxy.UseDefaultCredentials = true;
client.Proxy = myProxy;
string json = client.DownloadString(url);
Location location = new JavaScriptSerializer().Deserialize<Location>(json);
locations.Add(location);
...
All-Star
35218 Points
9955 Posts
Moderator
Geolocator app giving me fits
Oct 15, 2014 06:20 AM|bbcompent1|LINK
Split off from http://forums.asp.net/t/2013257.aspx?GeoIP+app+works+in+development+but+not+when+deployed+to+IIS+8
Proxy Server Problem: Ok, I figured out what is causing the issue. We have a proxy server here so I need to pass either the requesting AUTH_USER to the proxy or the configured identity user (Service Account) to tell the Proxy that the request is ok. How can I do this in C#?
When I run the tool on my Production box, I get this when it checks the IP vs the IP GEO Database.
All-Star
48280 Points
17983 Posts
Re: Geolocator app giving me fits
Oct 16, 2014 07:23 AM|PatriceSc|LINK
Try perhaps http://msdn.microsoft.com/en-us/library/system.net.webclient.proxy(v=vs.110).aspx and its credential property.
All-Star
35218 Points
9955 Posts
Moderator
Re: Geolocator app giving me fits
Oct 16, 2014 07:43 AM|bbcompent1|LINK
I have been trying different iterations of setting a proxy but I cannot seem to figure it out.
My error:
System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required. at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at FetchGeoIPData_IPAddress.btnGetGeoIPData_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\FetchGeoIPData_IPAddress.aspx.cs:line 78
Code:
All-Star
35218 Points
9955 Posts
Moderator
Re: Geolocator app giving me fits
Oct 26, 2014 04:44 PM|bbcompent1|LINK
Its a proxy server issue. Have to build in the proxy authentication.