469,645 Members | 1,514 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

WebClient form Posting with form name?

How does one post to an ASPX page using the WebClient when the form
name is required?
Nov 17 '05 #1
2 2214
"John Saunders" <jo***********@surfcontrol.com> wrote in message news:<Or**************@TK2MSFTNGP12.phx.gbl>...
"Jeff Baker" <jb*****@hotmail.com> wrote in message
news:78*************************@posting.google.co 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??
Nov 17 '05 #2
"Jeff Baker" <jb*****@hotmail.com> wrote in message
news:78**************************@posting.google.c om...
"John Saunders" <jo***********@surfcontrol.com> wrote in message

news:<Or**************@TK2MSFTNGP12.phx.gbl>...
"Jeff Baker" <jb*****@hotmail.com> wrote in message
news:78*************************@posting.google.co 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
jo***********@surfcontrol.com
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by mc kim via .NET 247 | last post: by
1 post views Thread by Adnan Selimovic | last post: by
reply views Thread by Kumar | last post: by
3 posts views Thread by Manuel | last post: by
3 posts views Thread by bss2004 | last post: by
2 posts views Thread by marfi95 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.