Sunday, August 8, 2010

C# FAQs Series: Using Proxy

In C# FAQs Series: We discuss most frequent questions asked on C# forums.
One of the most questions asked on C# froums is, how to use proxy settings in your own C# application.
You can programmatically change IE setting from registry using C#.
However the best way is to keep setting in your own application.
Updating IE settings:-

RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", "");
Control Settings in C# Application:-

YourWebService ws=new YourWebService();
System.Net.NeworkCredential cr= new System.Net.NeworkCredential("User","pwd","domain");
System.Net.WebProxy pr=new System.Net.WebProxy ("", 80);
To reset default settings...

No comments:

Post a Comment