Re: set field in web page

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ken Cox [Microsoft MVP] (BANSPAMken_cox_at_sympatico.ca)
Date: 06/30/04


Date: Tue, 29 Jun 2004 23:12:58 -0400

Hi Gary,

This is in VB.NET but it should give you the idea.

Find out what the target page wants to see as far as field names and the
submit button. Put those values into the NameValueCollection. Upload that
using UploadValues and read the result.

You can call this routine on the click event of your own page. Just change
the URL and the form field names/values.

  Sub DoPost()
        Dim uriString As String = _
        "http://p4320/p4320work/login.aspx"
        ' Create a new WebClient instance.
        Dim myWebClient As New System.Net.WebClient
        Dim myNameValueCollection As New _
          System.Collections.Specialized.NameValueCollection
        myNameValueCollection.Add("txtName", "Ken")
        myNameValueCollection.Add("txtPwd", "password")
        myNameValueCollection.Add("Button1", "")
        Dim responseArray As Byte() = myWebClient.UploadValues _
        (uriString, "POST", myNameValueCollection)
        Label1.Text = "Response received was :" & _
        System.Text.Encoding.ASCII.GetString(responseArray)
    End Sub

Ken
Microsoft MVP [ASP.NET]

"garyfehr" <garyfehr@discussions.microsoft.com> wrote in message
news:3F8667C4-F0B0-4740-BA4D-8F0394CD234A@microsoft.com...
>I think I wasn't specific enough or else I didn't understand your reply.
>What I want to do is visit a web page of a vendor and log in
>programmatically - the same as if I were sitting at a browser and typing in
>a username/password. So the first step would be to retrieve the login page
>of the vendor (which you've explained), then populate the appropriate
>fields on the page with username/password, then post this and retrieve the
>resulting response containing the page appearing after login.
>



Relevant Pages

  • AD authentication error handling
    ... I've created a login page to connect to Active Directory and retrieve a list ... If someone enters the wrong username/password, ... Anyone know how to handle this error so I can push out a login arror page? ... Set objConnection = CreateObject ...
    (microsoft.public.inetserver.asp.general)
  • Re: Get data from another website.
    ... > I need to go to another website, login with a username/password and ... > I've done this in VB using the MS WebBrowser, Navigating to the login ... > Then I just have to retrieve the data from the WebBrowser. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Get data from another website.
    ... I need to go to another website, login with a username/password and ... I've done this in VB using the MS WebBrowser, Navigating to the login ... Then I just have to retrieve the data from the WebBrowser. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: C/VB dll for "browsing" large datasets?
    ... We did a massive project where the total database size is over 80GB with ... Gods name are you allowing users to retrieve such large sets of data. ... fetching from FoxPro will improve the thru-put. ... Most of the queries are simply pulling a vendor to work. ...
    (microsoft.public.fox.programmer.exchange)
  • CERT Advisory CA-2001-34 Buffer Overflow in System V Derived Login
    ... Several applications use login for authentication to the system. ... System V. Attackers can exploit this vulnerability to gain root access ... vendor is not listed below, we have not received their comments. ...
    (Cert)