HighTechTalks DotNet Forums  

using a cookie with System.Net.WebClient

Dotnet Framework (WinForms) microsoft.public.dotnet.framework.windowsforms


Discuss using a cookie with System.Net.WebClient in the Dotnet Framework (WinForms) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jeroen
 
Posts: n/a

Default using a cookie with System.Net.WebClient - 07-06-2005 , 04:07 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.A SCII,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/ =-


Reply With Quote
  #2  
Old   
Joerg Jooss
 
Posts: n/a

Default Re: using a cookie with System.Net.WebClient - 07-06-2005 , 04:24 PM






Jeroen wrote:

Quote:
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.A SCII,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)
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
mailto:news-reply (AT) joergjooss (DOT) de


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.