Prev: The result for select user_name(), current_name
Next: Help with FtpWebRequest (UploadFile status/progress)
From: Durango2008 on 6 Jan 2010 21:39 Hello I am not sure if this is the correct area to ask this. I am working on an application to read some data from a website that requires a login. I am using the WebClient class to read the page. For example if I have a page http://www.something.com it can read the page fine. However If I have a page https://www.something.com/secure/ than it requires authentication. I have the username/password required I just need to know how to pass it in using C# .net. Thank you for any help. --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Alexey Smirnov on 7 Jan 2010 03:40
On Jan 7, 3:39 am, "Durango2008" <el_dura...(a)yah00.c0m> wrote: > Hello I am not sure if this is the correct area to ask this. > > I am working on an application to read some data from a website that > requires a login. > > I am using the WebClient class to read the page. > > For example if I have a pagehttp://www.something.comit can read the page > fine. > > However If I have a pagehttps://www.something.com/secure/than it requires > authentication. > > I have the username/password required I just need to know how to pass it in > using C# .net. > > Thank you for any help. > > --- news://freenews.netfront.net/ - complaints: n...(a)netfront.net --- If this is about Basic Authentication then look at NetworkCredential http://msdn.microsoft.com/en-us/library/system.net.networkcredential.aspx e.g. Uri url = new Uri(@"http://some.url/server/somebscwserver.cgi"); HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://..."); NetworkCredential myCredentials = new NetworkCredential( "username", "password"); CredentialCache myCredentialCache = new CredentialCache(); MyCredentialCache.Add(url, "Basic", myCredential); req.Credentials = myCredentialCache; System.IO.Stream response = req.GetResponse().GetResponseStream(); |