Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > WebClient form Posting with form name?

Reply
Thread Tools

WebClient form Posting with form name?

 
 
Jeff Baker
Guest
Posts: n/a
 
      08-28-2003
How does one post to an ASPX page using the WebClient when the form
name is required?
 
Reply With Quote
 
 
 
 
Jeff Baker
Guest
Posts: n/a
 
      08-29-2003
"John Saunders" <(E-Mail Removed)> wrote in message news:<OrPU$(E-Mail Removed)>...
> "Jeff Baker" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) m...
> > How does one post to an ASPX page using the WebClient when the form
> > name is required?

>
> Could you be more specific?



Dim client As New WebClient

client.Headers.Add("Content-Type",
"application/x-www-form-urlencoded")
Dim myQueryStringCollection As New
System.Collections.Specialized.NameValueCollection

myQueryStringCollection.Add("username", "test")
myQueryStringCollection.Add("password", "tickle")

client.QueryString = myQueryStringCollection
Dim ResponseData As Byte() =
client.DownloadData("http://www.mytestsite.com/index.aspx")

From the code above I'm posting the "username" and "password" to the
"index.aspx" page and downloading the page ingo the ResponseData Byte
array. What happens if the index.aspx page has more than one form and
I want to post to a specific form OR if the index.aspx page is
specifically looking for a form name to via the request object??

How can I specifiy the form name when using the WebClient class to
post information to a page/form??
 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      08-29-2003
"Jeff Baker" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "John Saunders" <(E-Mail Removed)> wrote in message

news:<OrPU$(E-Mail Removed)>...
> > "Jeff Baker" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) m...
> > > How does one post to an ASPX page using the WebClient when the form
> > > name is required?

> >
> > Could you be more specific?

>
>
> Dim client As New WebClient
>
> client.Headers.Add("Content-Type",
> "application/x-www-form-urlencoded")
> Dim myQueryStringCollection As New
> System.Collections.Specialized.NameValueCollection
>
> myQueryStringCollection.Add("username", "test")
> myQueryStringCollection.Add("password", "tickle")
>
> client.QueryString = myQueryStringCollection
> Dim ResponseData As Byte() =
> client.DownloadData("http://www.mytestsite.com/index.aspx")
>
> From the code above I'm posting the "username" and "password" to the
> "index.aspx" page and downloading the page ingo the ResponseData Byte
> array. What happens if the index.aspx page has more than one form and
> I want to post to a specific form OR if the index.aspx page is
> specifically looking for a form name to via the request object??
>
> How can I specifiy the form name when using the WebClient class to
> post information to a page/form??


WebClient.QueryString gets/sets the query string. You are downloading from

http://www.mytestsite.com/index.aspx...assword=tickle.

You aren't POSTing at all, you're using a GET.

See a recent thread in this newsgroup called "Going crazy over HTTP Post
from class library". Make sure you read the entire thread!
--
John Saunders
Internet Engineer
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File uploading along with form elements using WebRequest or WebClient natzol ASP .Net 0 12-01-2006 07:15 PM
WebClient Not posting to Client Tom ASP .Net Web Services 1 02-02-2005 04:33 PM
WebClient not posting data. Manuel ASP .Net 3 11-03-2004 08:54 PM
submit form via HttpWebRequest or WebClient John A Grandy ASP .Net 14 08-26-2004 10:16 PM
Using .net to enter form values (WebClient) Tom Yates ASP .Net 2 10-27-2003 02:44 PM



Advertisments