[英]how to use the windows login credentials for proxy authentication using C#
Is it possbile to use the windows login credential for proxy authentication using C#. 是否可以使用Windows登录凭证进行使用C#进行代理身份验证。
I have a facebook application, which calls the facebook methods. 我有一个facebook应用程序,它调用facebook方法。 During every facebook call, it gives an error "407: proxy authentication required"
在每次facebook通话期间,它都会出现错误“407:需要代理身份验证”
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. 但是,如果不对我公司的登录凭据进行硬编码,是否还有其他方法可以做同样的事情。
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 如果它仍然无法解决您的问题,请访问该网站: http : //support.microsoft.com/kb/813834
Try creating a WebProxy with a default constructor (don't supply the proxy server) and see if it works for you.. 尝试使用默认构造函数创建WebProxy(不提供代理服务器),看看它是否适合您。
WebProxy oWebProxy = new System.Net.WebProxy();
The default constructor will take the credentials from the system as you entered them in your web browser.. 当您在Web浏览器中输入凭据时,默认构造函数将从系统获取凭据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.