I am getting Internal Server error 500 while making a call to WCF service from code behind. I am not using any proxy or reference but trying to make a call with HTTPWebRequest object.
I have my application pool running under some service account and WCF service requires the call to be made under windows credentials only. Code works fine if I change the identity of apppool to my windows credentials, but need is to run my appool under service account only.
So, my primary question is how do I make this call with windows Credentials ? I tried following but none of them worked :
Uri uri = new Uri(myServiCeUrl); ICredentials credentials = CredentialCache.DefaultCredentials; NetworkCredential credential = credentials.GetCredential(uri, "Basic"); webRequest.Credentials = credential;
- webRequest.UseDefaultCredentials = true;
- webRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
- webRequest.Credentials = (ICredentials)System.Security.Principal.WindowsIdentity.GetCurrent(true);
- webRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
Please help and share your thoughts.