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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…