I am trying to get some data from a web site that has form-based
authentication (username/password with submitt button).

So I just need to write software to go to the URL, enter the username and
password and download the information from the resulting page.

Does anyone know how to do this - that is entering the username and
password?

(I can tried to add CredentialCache object to a WebRequest but I think I
need to somehow Post the username and password information to the page.)

Brian

RE: Simple web request? by jchREMOVE

jchREMOVE
Mon Jun 28 08:37:02 CDT 2004

Hey Brian,

Use the HttpWebRequest class to make HTTP requests. Use the property HttpWebRequest.Method to specify that you wish to use HTTP POST. After that you can use the HttpWebRequest.GetRequestStream method to retrieve a stream to which you can write the post data such as username and password. Check the HTML of the web site to see the names of the input fields for the username and password.

See the docs for a short example: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnethttpwebrequestclassgetrequeststreamtopic.asp

Regards, Jakob.


"Brian Taylor" wrote:

> I am trying to get some data from a web site that has form-based
> authentication (username/password with submitt button).
>
> So I just need to write software to go to the URL, enter the username and
> password and download the information from the resulting page.
>
> Does anyone know how to do this - that is entering the username and
> password?
>
> (I can tried to add CredentialCache object to a WebRequest but I think I
> need to somehow Post the username and password information to the page.)
>
> Brian
>
>
>

Re: Simple web request? by Brian

Brian
Wed Jun 30 23:25:10 CDT 2004

Thanks Jakob this look just what I need. I'll give it a go and post any
further problems if I get them.

Brian


"Jakob Christensen" <jchREMOVE@pension.dk> wrote in message
news:E6D390F3-5F5C-4CAE-8318-932E6C5EAB4C@microsoft.com...
> Hey Brian,
>
> Use the HttpWebRequest class to make HTTP requests. Use the property
HttpWebRequest.Method to specify that you wish to use HTTP POST. After
that you can use the HttpWebRequest.GetRequestStream method to retrieve a
stream to which you can write the post data such as username and password.
Check the HTML of the web site to see the names of the input fields for the
username and password.
>
> See the docs for a short example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemnethttpwebrequestclassgetrequeststreamtopic.asp
>
> Regards, Jakob.
>
>
> "Brian Taylor" wrote:
>
> > I am trying to get some data from a web site that has form-based
> > authentication (username/password with submitt button).
> >
> > So I just need to write software to go to the URL, enter the username
and
> > password and download the information from the resulting page.
> >
> > Does anyone know how to do this - that is entering the username and
> > password?
> >
> > (I can tried to add CredentialCache object to a WebRequest but I think I
> > need to somehow Post the username and password information to the page.)
> >
> > Brian
> >
> >
> >



Re: Simple web request? by feroze

feroze
Thu Jul 01 01:17:02 CDT 2004

If all you want to do is post to a form, just use WebClient. It has an
UploadValues method, which will do the right thing for you.

feroze
===========

"Brian Taylor" <taylorb@newsgroups.nospam> wrote in message
news:%23kR7hMyXEHA.2520@TK2MSFTNGP12.phx.gbl...
> Thanks Jakob this look just what I need. I'll give it a go and post any
> further problems if I get them.
>
> Brian
>
>
> "Jakob Christensen" <jchREMOVE@pension.dk> wrote in message
> news:E6D390F3-5F5C-4CAE-8318-932E6C5EAB4C@microsoft.com...
> > Hey Brian,
> >
> > Use the HttpWebRequest class to make HTTP requests. Use the property
> HttpWebRequest.Method to specify that you wish to use HTTP POST. After
> that you can use the HttpWebRequest.GetRequestStream method to retrieve a
> stream to which you can write the post data such as username and password.
> Check the HTML of the web site to see the names of the input fields for
the
> username and password.
> >
> > See the docs for a short example:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
> frlrfsystemnethttpwebrequestclassgetrequeststreamtopic.asp
> >
> > Regards, Jakob.
> >
> >
> > "Brian Taylor" wrote:
> >
> > > I am trying to get some data from a web site that has form-based
> > > authentication (username/password with submitt button).
> > >
> > > So I just need to write software to go to the URL, enter the username
> and
> > > password and download the information from the resulting page.
> > >
> > > Does anyone know how to do this - that is entering the username and
> > > password?
> > >
> > > (I can tried to add CredentialCache object to a WebRequest but I think
I
> > > need to somehow Post the username and password information to the
page.)
> > >
> > > Brian
> > >
> > >
> > >
>
>



Re: Simple web request? by Brian

Brian
Sat Jul 03 19:27:01 CDT 2004

Well thanks Jakob and Feroze - with this information I managed to get both
methods working.
The WebClient method does not seem to pass the Cookie information (used to
keep the login context) between pages so I ended up using the Cookie
properties in HttpWebRequest and HttpWebResponse to do this.

Thanks,
Brian

"feroze [msft]" <ferozed@online.microsoft.com> wrote in message
news:40e3ac62$1@news.microsoft.com...
> If all you want to do is post to a form, just use WebClient. It has an
> UploadValues method, which will do the right thing for you.
>
> feroze
> ===========
>
> "Brian Taylor" <taylorb@newsgroups.nospam> wrote in message
> news:%23kR7hMyXEHA.2520@TK2MSFTNGP12.phx.gbl...
> > Thanks Jakob this look just what I need. I'll give it a go and post any
> > further problems if I get them.
> >
> > Brian
> >
> >
> > "Jakob Christensen" <jchREMOVE@pension.dk> wrote in message
> > news:E6D390F3-5F5C-4CAE-8318-932E6C5EAB4C@microsoft.com...
> > > Hey Brian,
> > >
> > > Use the HttpWebRequest class to make HTTP requests. Use the property
> > HttpWebRequest.Method to specify that you wish to use HTTP POST. After
> > that you can use the HttpWebRequest.GetRequestStream method to retrieve
a
> > stream to which you can write the post data such as username and
password.
> > Check the HTML of the web site to see the names of the input fields for
> the
> > username and password.
> > >
> > > See the docs for a short example:
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
> > frlrfsystemnethttpwebrequestclassgetrequeststreamtopic.asp
> > >
> > > Regards, Jakob.
> > >
> > >
> > > "Brian Taylor" wrote:
> > >
> > > > I am trying to get some data from a web site that has form-based
> > > > authentication (username/password with submitt button).
> > > >
> > > > So I just need to write software to go to the URL, enter the
username
> > and
> > > > password and download the information from the resulting page.
> > > >
> > > > Does anyone know how to do this - that is entering the username and
> > > > password?
> > > >
> > > > (I can tried to add CredentialCache object to a WebRequest but I
think
> I
> > > > need to somehow Post the username and password information to the
> page.)
> > > >
> > > > Brian
> > > >
> > > >
> > > >
> >
> >
>
>



Re: Simple web request? by yoliprimavera

yoliprimavera
Wed Jul 14 10:07:55 CDT 2004

I have the same problem......!
I need to keep the Session ID and then send a second Request wit the
username and password.

How do you finally integrate the second response?


string LoginCookies = wReq.CookieContainer.GetCookieHeader( ePageUri
).ToString();
NameValueCollection form = new NameValueCollection();
form.Add("email", "demo");
form.Add("password", "pass");

WebClient eClient = new WebClient();
eClient.Headers.Add("HTTP_USER_AGENT", "Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.1; YComp 5.0.0.0; .NET CLR 1.0.3705)");
eClient.Headers.Add("Cookie", LoginCookies);

Byte[] responseData =
eClient.UploadValues(@"http://www.login.com/logincustomer.asp", "POST",
form);
string ResponseHtml = Encoding.ASCII.GetString( responseData );

But didnt work........ !!

Can you help me please !


> Brian Taylorwrote:
Well thanks Jakob and Feroze - with this information I managed to get
both
> methods working.
> The WebClient method does not seem to pass the Cookie information
(used to
> keep the login context) between pages so I ended up using the
Cookie
> properties in HttpWebRequest and HttpWebResponse to do this.
>
> Thanks,
> Brian
>



> Brian Taylorwrote:
Well thanks Jakob and Feroze - with this information I managed to get
both
> methods working.
> The WebClient method does not seem to pass the Cookie information
(used to
> keep the login context) between pages so I ended up using the
Cookie
> properties in HttpWebRequest and HttpWebResponse to do this.
>
> Thanks,
> Brian
>


Re: Simple web request? by yoliprimavera

yoliprimavera
Wed Jul 14 10:07:55 CDT 2004

I have the same problem......!
I need to keep the Session ID and then send a second Request wit the
username and password.

How do you finally integrate the second response?


string LoginCookies = wReq.CookieContainer.GetCookieHeader( ePageUri
).ToString();
NameValueCollection form = new NameValueCollection();
form.Add("email", "demo");
form.Add("password", "pass");

WebClient eClient = new WebClient();
eClient.Headers.Add("HTTP_USER_AGENT", "Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.1; YComp 5.0.0.0; .NET CLR 1.0.3705)");
eClient.Headers.Add("Cookie", LoginCookies);

Byte[] responseData =
eClient.UploadValues(@"http://www.login.com/logincustomer.asp", "POST",
form);
string ResponseHtml = Encoding.ASCII.GetString( responseData );

But didnt work........ !!

Can you help me please !


> Brian Taylorwrote:
Well thanks Jakob and Feroze - with this information I managed to get
both
> methods working.
> The WebClient method does not seem to pass the Cookie information
(used to
> keep the login context) between pages so I ended up using the
Cookie
> properties in HttpWebRequest and HttpWebResponse to do this.
>
> Thanks,
> Brian
>


Re: Simple web request? by yoliprimavera

yoliprimavera
Wed Jul 14 13:31:44 CDT 2004

I have the same problem......!
I need to keep the Session ID and then send a second Request wit the
username and password.

How do you finally integrate the second response?


string LoginCookies = wReq.CookieContainer.GetCookieHeader( ePageUri
).ToString();
NameValueCollection form = new NameValueCollection();
form.Add("email", "demo");
form.Add("password", "pass");

WebClient eClient = new WebClient();
eClient.Headers.Add("HTTP_USER_AGENT", "Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.1; YComp 5.0.0.0; .NET CLR 1.0.3705)");
eClient.Headers.Add("Cookie", LoginCookies);

Byte[] responseData =
eClient.UploadValues(@"http://www.login.com/logincustomer.asp",
"POST", form);
string ResponseHtml = Encoding.ASCII.GetString( responseData );

But didnt work........ !!

Can you help me please !