locked
Geolocator app giving me fits RRS feed

  • Question

  • User-718146471 posted

    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.

    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

     

    Wednesday, October 15, 2014 6:20 AM

Answers

  • User-718146471 posted

    Its a proxy server issue.  Have to build in the proxy authentication.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 26, 2014 4:44 PM

All replies

  • User753101303 posted

    Try perhaps  http://msdn.microsoft.com/en-us/library/system.net.webclient.proxy(v=vs.110).aspx and its credential property.

    Thursday, October 16, 2014 7:23 AM
  • User-718146471 posted

    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);
    ...

    Thursday, October 16, 2014 7:43 AM
  • User-718146471 posted

    Its a proxy server issue.  Have to build in the proxy authentication.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 26, 2014 4:44 PM