WebClient form Posting with form name?

Discussion in 'ASP .Net' started by Jeff Baker, Aug 28, 2003.

  1. Jeff Baker

    Jeff Baker Guest

    How does one post to an ASPX page using the WebClient when the form
    name is required?
     
    Jeff Baker, Aug 28, 2003
    #1
    1. Advertising

  2. Jeff Baker

    Jeff Baker Guest

    "John Saunders" <> wrote in message news:<OrPU$>...
    > "Jeff Baker" <> wrote in message
    > news:...
    > > 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??
     
    Jeff Baker, Aug 29, 2003
    #2
    1. Advertising

  3. "Jeff Baker" <> wrote in message
    news:...
    > "John Saunders" <> wrote in message

    news:<OrPU$>...
    > > "Jeff Baker" <> wrote in message
    > > news:...
    > > > 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?username=test&password=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
     
    John Saunders, Aug 29, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manuel

    WebClient not posting data.

    Manuel, Nov 2, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    6,689
    Joerg Jooss
    Nov 3, 2004
  2. Replies:
    3
    Views:
    673
  3. Tom

    WebClient Not posting to Client

    Tom, Feb 1, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    128
  4. Pavils Jurjans
    Replies:
    3
    Views:
    208
    Pavils Jurjans
    Mar 18, 2005
  5. Replies:
    6
    Views:
    191
Loading...

Share This Page