469,579 Members | 1,040 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

HTTPWebRequest, Proxy, Credentials?

moo
Is there a simple way to get my logon credentials to make my web request
work through our proxy server? I tried CredentialCache.DefaultCredentials,
but I get nothing back. I can get it to work if I just create a new
NetworkCredential object specifying user, password and domain. But, I would
rather get that info automatically if possible, rather than presenting a
winform for them to type it in.

Lastly, why do both the request object and the request's proxy object have
properties for credentials? Do I need to populate them both?

Thanks,
// WebRequest
HttpWebRequest webRequest =
(HttpWebRequest)WebRequest.Create(anyURL);
webRequest.Timeout = 10000;
webRequest.CookieContainer = cookieContainer;

// Proxy Credentials?
webRequest.Proxy = WebProxy.GetDefaultProxy();
webRequest.Proxy.Credentials = new
NetworkCredential("XXX","YYY","ZZZ");

webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.Credentials = new
NetworkCredential("XXX","YYY","ZZZ");

Jul 25 '07 #1
1 3739
the proxy server is a local server used to access the internet, and
generally uses an internal account. the web server may have its own
login requirements and may use the same login (or method). when using a
proxy to access a local server the accounts may match.

CredentialCache.DefaultCredentials is the current threads nt security
token. if it doesn't work then its probably a local account without
network access. for asp.net use a domain pool account, and be sure
impersonation is off.

-- bruce (sqlwork.com)

moo wrote:
Is there a simple way to get my logon credentials to make my web request
work through our proxy server? I tried CredentialCache.DefaultCredentials,
but I get nothing back. I can get it to work if I just create a new
NetworkCredential object specifying user, password and domain. But, I would
rather get that info automatically if possible, rather than presenting a
winform for them to type it in.

Lastly, why do both the request object and the request's proxy object have
properties for credentials? Do I need to populate them both?

Thanks,
// WebRequest
HttpWebRequest webRequest =
(HttpWebRequest)WebRequest.Create(anyURL);
webRequest.Timeout = 10000;
webRequest.CookieContainer = cookieContainer;

// Proxy Credentials?
webRequest.Proxy = WebProxy.GetDefaultProxy();
webRequest.Proxy.Credentials = new
NetworkCredential("XXX","YYY","ZZZ");

webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.Credentials = new
NetworkCredential("XXX","YYY","ZZZ");


Jul 25 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by d2005\\ | last post: by
1 post views Thread by Imran Aziz | last post: by
2 posts views Thread by =?Utf-8?B?TGFycnlLdXBlcm1hbg==?= | last post: by
2 posts views Thread by =?Utf-8?B?TGVuc3Rlcg==?= | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.