I'm trying to request a url that requires windows authentication using HttpWebRequest , I used
request.Credential = New NetworkCredential("username", "password");
everything worked until I decided not to write down the username and password, and switch to
request.Credential = CredentialCache.DefaultNetworkCredentials;
then I got 401 unauthenticated error. I checked my user with
WindowsIdentity.GetCurrent();
It returns my username correctly, but
CredentialCache.DefaultNetworkCredentials;
return me an empty string for the username, domain ... almost all empty string. Too bad that HttpWebRequest.Credential expects ICredential means that I cannot set WindowsIdentity.GetCurrent () for it.
Anyway, can I pass my current login user to HttpWebRequest.Credential ??
Is CredentialCache.DefaultNetworkCredentials; in the right way? or are they just missing some settings?
I read some artistic, like this http://msdn.microsoft.com/en-us/library/ms998351.aspx .
Is this understanding too long and too complicated for me, or it does not work. I am new to this, hope to get a direct answer here.