How to use proxy (driven by config parameters)

Web.Config

<pre>
    &lt;add key="RCT-Use-Proxy" value="true" /&gt;
    &lt;add key="RCT-Proxy"     value="http://10.101.101.101:8080" /&gt;
</pre>

C# Code:

<pre>

            string strUseProxy = ConfigurationManager.AppSettings["RCT-Use-Proxy"];
            string strProxy = ConfigurationManager.AppSettings["RCT-Proxy"];
            bool useProxy = System.Convert.ToBoolean(strUseProxy);
            if (useProxy)
            {
                valservice.Proxy = new System.Net.WebProxy(strProxy, true);
            }

</pre>

Uncategorized  

Leave a Reply