views:

109

answers:

2

Is it possbile to use the windows login credential for proxy authentication using C#.

I have a facebook application, which calls the facebook methods. During every facebook call, it gives an error "407: proxy authentication required"

The following code will allow the user to set the proxy :-

WebProxy oWebProxy = new System.Net.WebProxy(ProxyServer, ProxyPort);       
oWebProxy.Credentials = new NetworkCredential(ProxyUser,ProxyPassword,ProxyDomain);
oserv.Proxy = oWebProxy; 
oserv.Credentials = new NetworkCredential(theusername, thepassword); 

But, is there any other way of doing the same thing without hardcoding my company's login credentials.

+1  A: 

Try creating a WebProxy with a default constructor (don't supply the proxy server) and see if it works for you..

WebProxy oWebProxy = new System.Net.WebProxy();

The default constructor will take the credentials from the system as you entered them in your web browser..

Gilad
+1  A: 

You can use :

oWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

If it still does not solve your problem, then please refer to the site : http://support.microsoft.com/kb/813834

Siva Gopal
thanks a lot :)
Adi_aks