I'm trying to figure out how to use the System.Net.WebRequest class to send my credentials when the Apache server has a .htaccess file protecting access. It appears to be something to do with the Credentials property (imagine that!) but I am not sure how to create the correct ICredentials object. Sample code = accepted answer.
views:
462answers:
1
+3
A:
System.Net.CredentialCache aCredentialCache = new System.Net.CredentialCache();
aCredentialCache.Add(new Uri("www.yoursite.com"), "Basic", new System.Net.NetworkCredential("User", "Password"));
System.Net.WebRequest aRequest = System.Net.WebRequest.Create("www.yoursite.com");
aRequest.Credentials = aCredentialCache;
Rick Mogstad
2009-05-29 20:03:22
Thanks! And welcome to the site
Luke
2009-05-29 20:34:13