Wednesday, March 13, 2013

C# code to Check IE Proxy Settings

private static void CheckIEProxySettings()
{
    string strFileURL = "http://programmersvision.blogspot.in";
    HttpWebRequest WebReqt = (HttpWebRequest)HttpWebRequest.Create(strFileURL);
    WebProxy WP = new WebProxy(WebReqt.Proxy.GetProxy(new Uri(strFileURL)));
    WP.Credentials = CredentialCache.DefaultCredentials;
    Console.WriteLine(WP.Address);
    // or use this method
    //CheckForProxy(new Uri("http://http://programmersvision.blogspot.in"));
}

private static void CheckForProxy(Uri resource)
{
    WebProxy proxy = (WebProxy)WebProxy.GetDefaultProxy();
    Uri proxyUri = proxy.GetProxy(resource);
    if (proxyUri == resource)
    {
        Console.WriteLine("There is no proxy for {0}", resource);
    }
    else
    {
        Console.WriteLine("Proxy for {0} is {1}", resource, proxyUri.ToString());
    }
}

3 comments:

  1. I'm really impressed with your writing skills and also with the format on your weblog.
    access Mp3Raid in UK

    ReplyDelete
  2. WOW!! terribly informative web log and helpful techniques. Please visit this web site if you wish a lot of detail.
    access BitSnoop in UK

    ReplyDelete
  3. very nice and helpfull article.The translation service is really very helpful to me.
    access FileCrop in UK

    ReplyDelete