|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Set credentials to a web requestHi,
I'm trying to run an automated test (using NTime tool) on a web application (windows authentication). All calls in this web app are intercepted by a custom httpModule. I'm setting credentials to the web request so that the authentication passes but this doesn't seem to work: NetworkCredential obj = new NetworkCredential(); obj.UserName = @"domain\username"; obj.Password = "test123"; HttpWebRequest myRequest = (HttpWebRequest) HttpWebRequest.Create("https://testsite.com/testapp/samplepage.aspx"); myRequest.Credentials = obj; Please suggest the solution. Thanks Hello, Nonnie!
N> NetworkCredential obj = new NetworkCredential(); N> obj.UserName = @"domain\username"; N> obj.Password = "test123"; N> HttpWebRequest myRequest = (HttpWebRequest) N> HttpWebRequest.Create("https://testsite.com/testapp/samplepage.aspx"); N> myRequest.Credentials = obj; What type authentication do you use? You can try this CredentialCache myCache = new CredentialCache(); NetworkCredential netCredential = new NetworkCredential(UserName,SecurelyStoredPassword,Domain); myCache.Add(new Uri("https://testsite.com/testapp/samplepage.aspx"),"Basic", netCredential); myCache.Add(new Uri("https://testsite.com/testapp/samplepage.aspx"),"Digest", netCredential); myCache.Add(new Uri("https://testsite.com/testapp/samplepage.aspx"),"Negotiate", netCredential); myRequest.Credentials = myCache; |
|||||||||||||||||||||||