0
Reply

Accessing secure http

jcwright77

jcwright77

Jun 16 2004 11:39 AM
1.5k
Here is the scenario. I have an http site that pops up a request for a username and password before you can enter any part of it. The reason for gaining access is so that I can read an XML file (achieved w/out user/pass) and download a file (achieved w/out user/pass). Both of these are on seperate places on the http site. The question is, how can I make my C# program automatically enter the username and password (silently) so that I can then do my business? Username and password is provided in the code. Here is what I am working with: public static void Connect() { string url = ConfigurationSettings.AppSettings[@"mainSite"]; string username = ConfigurationSettings.AppSettings["username"]; string password = ConfigurationSettings.AppSettings["password"]; HttpWebRequest request =(HttpWebRequest)HttpWebRequest.Create(url); request.Method = "POST"; using (StreamWriter sw = new StreamWriter((request.GetRequestStream())); sw.Write("Username="+username+"&Password="+password); HttpWebResponse response = (HttpWebResponse) request.GetResponse(); } It fails on the getrequest stream, but I am unsure about what to write to the stream.

Next Recommended Forum