all groups > dotnet windows forms > july 2005 >
You're in the

dotnet windows forms

group:

using a cookie with System.Net.WebClient


Re: using a cookie with System.Net.WebClient Joerg Jooss
7/6/2005 2:24:06 PM
dotnet windows forms:
[quoted text, click to view]

I don't know why you post this to the Windows Forms group -- there's a
Framework group for that.

Anyway, you have to use a CookieContainer object in combination with a
HttpWebRequest -- WebClient isn't sophisticated enough for this use
case.

Cheers,
--
http://www.joergjooss.de
using a cookie with System.Net.WebClient Jeroen
7/6/2005 11:07:22 PM
Hi,

i use aan application to download an aspx file, and check ik for some values.
But there had been a change, there is a login script that checks if you have a cookie, if not it show a "username/password" screen (url remains the same)

i know the username password, and if i fill it once my browser never shows it anymore.
But how can i use this cookie to still download te aspx?

this is my current code:

System.Net.WebClient Client = new System.Net.WebClient();
System.IO.Stream strm = Client.OpenRead(@"http://url.to/myfile.aspx");
System.IO.StreamReader sr = new System.IO.StreamReader(strm,System.Text.Encoding.ASCII,false,20480);
string x;

do
{
x = sr.ReadLine() ;
// check some stuff
}
while (x !=null);
strm.Close();

Now it stream only contains the source of the "login page" and not the source after you've entered the username / pwd.

does anyone know how to combine this with a cookie? (i know which one it is in my cookies directorie)

Thanks for thinking with me.
Jeroen


--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
AddThis Social Bookmark Button