I have an ASP.NET MVC 4 web service. On my dev box, I'm running IIS Express 7.5, so we're calling localhost:port. I have set it to use Windows Authentication and switched off Anonymous.
On my client, if I set
HttpWebRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
it works. But if I set the credentials to my other Windows domain account,
HttpWebRequest.Credentials = new NetworkCredential("lpuplett", "catsGoW00f", "ntdom"));
then I get a 401 Unauthorized. Am I misunderstanding something; should this work?
I've tried adding the credentials to a CredentialCache object and setting the cache.
From comment in linked duplicate question:
You need to specify the authentication type. When the server challenges the client with NTLM authentication the ICredentials.GetCredential method will be called on WebClient.Credentials with authType = "NTLM". If you used WebClient.Credential = new NetworkCredential(...) as no authentication type is specified the client won't be able to respond correctly. CredentialCache already implements this functionality. – Darin Dimitrov Nov 5 '09 at 14:57
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With