开发者

NetworkCredential, CredentialCache, ICredentials All return Nothing

开发者 https://www.devze.com 2023-03-20 01:40 出处:网络
I have a Windows Form app and it keeps returning a 407 Proxy Server error when I try and return a JSON string from the Google servers.I have been led to believe that all I need to do is set the Securi

I have a Windows Form app and it keeps returning a 407 Proxy Server error when I try and return a JSON string from the Google servers. I have been led to believe that all I need to do is set the Security Context correctly by setting the WebRequest Credentials as "DefaultCredentials" or "DefaultNetworkCredentials". However, all the methods I have used (see subject tittle) have always returned "".

The annoying thing is that the app works perfectly when running on my machine, published and through VS 2008, but when other users try, it generates the below errror:

System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.

at System.开发者_StackOverflow中文版Net.HttpWebRequest.GetResponse()

Any ideas any one, before I go bald!

Thanks in advance

C

EDIT : Some code as requested. I have tried quite a few variations of the following, none seem to work.

request.Proxy.Credentials = CredentialCache.DefaultCredentials;
HttpWebRequest.Proxy.Credentials = CredentialCache.DefaultCredentials;

OR string url = "http://www.blah.com"; Uri uri = new Uri(url); ICredentials credentials = CredentialCache.DefaultCredentials; NetworkCredential credential = credentials.GetCredential(uri, "Basic");

OR

NetworkCredential credential = CredentialCache.DefaultNetworkCredentials;

INTO

request.Proxy.Credentials = CredentialCache.DefaultCredentials;

OR

request.Credentials = credential

I have also trid both

.DefaultCredentials

And

.DefaultNetworkCredentials


The credentials returned by DefaultNetworkCredentials represents the authentication credentials for the current security context in which the application is running. For a client-side application, these are usually the Windows credentials (user name, password, and domain) .

Probably the user who is running the application doesn't have the rights on the proxy

0

精彩评论

暂无评论...
验证码 换一张
取 消