I am integrating web service that will use an HTTP-POST to request and retrieve data. The remote server requires basic authentication as per RFC 2617
My attempts to authenticate are failing.
It fails in that, even though I attach a 'NetworkCredential' object to the 'Credentials' property of a 'HttpWebRequest' object, no authentication information is sent in the header, even if I set 'PreAuthenticate' = true.
What am I missing?
//chunk used
NetworkCredential netCredential = new NetworkCredential(" uid", "pwd");
Uri uri = new Uri("http://address of services");
ICredentials credentials = netCredential.GetCredential(uri, "Basic");
objRegistration.Credentials = credentials;
objRegistration.PreAuthenticate = true;
See Question&Answers more detail:os