RE: Automating dialog with web server from VB.NET

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Peter Huang (v-phuang_at_online.microsoft.com)
Date: 04/08/04


Date: Thu, 08 Apr 2004 03:25:32 GMT

Hi Mark,

First of all, I would like to confirm my understanding of your issue.
>From your description, I understand that you wants to post some data to a
names.nsf page.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Since I have no Lotus Notes web application at hand, I test on an aspx page.
Here is my code on client.
Imports System.Net
Imports System.Collections.Specialized
Imports System.Text
Module Module1
    Sub Main()
        'Dim o As New TestCls.TestABC
        'Console.WriteLine(o.Hello)
        Console.Write(ControlChars.Cr + "Please enter the URL to post data
to : ")
        Dim uriString As String =
"http://localhost/WebApplication6/WebForm1.aspx"
        ' Create a new WebClient instance.
        Dim myWebClient As New WebClient
        ' Create a new NameValueCollection instance to hold some custom
parameters to be posted to the URL.
        Dim myNameValueCollection As New NameValueCollection
        Console.WriteLine("Please enter the following parameters to be
posted to the Url")
        Console.Write("Name:")
        Dim name As String = "TestUser"
        Console.Write("Age:")
        Dim age As String = ""
        Console.Write("Address:")
        Dim address As String = ""
        ' Add necessary parameter/value pairs to the name/value container.
        myNameValueCollection.Add("Name", name)
        myNameValueCollection.Add("Address", address)
        myNameValueCollection.Add("Age", age)
        Console.WriteLine(ControlChars.Cr + "Uploading to {0} ...",
uriString)
        ' Upload the NameValueCollection.
        Dim responseArray As Byte() = myWebClient.UploadValues(uriString,
"POST", myNameValueCollection)
        ' Decode and display the response.
        Console.WriteLine(ControlChars.Cr + "Response received was :" +
ControlChars.Cr + "{0}", Encoding.ASCII.GetString(responseArray))
    End Sub
End Module

[aspx codebehind page]
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Request.Form("Name") = "TestUser" Then
            Response.Write("OK")
        End If
    End Sub

You may try my code first with an aspx page first to isolate the problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.



Relevant Pages

  • SplibVB<>aspx
    ... aspx - www ... Imports System.Configuration ... dim rek,serw ... sub displayMessage ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: how to open a file and save it local
    ... create a ashx page not a aspx page, ... Imports System.Web.Services ... Public Class word ... Sub ProcessRequestImplements ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Problems implementing the IMessageFilter to filter keypress events
    ... Imports System.Reflection ... Private Sub frmMain_Load(ByVal sender As Object, ...
    (microsoft.public.windowsce.app.development)
  • Re: Problems implementing the IMessageFilter to filter keypress ev
    ... >> Imports System.Data.SqlServerCe.SqlCeException ... >> Implements IMessageFilter ... >> Private Sub frmMain_Load(ByVal sender As Object, ...
    (microsoft.public.windowsce.app.development)
  • parameters
    ... The table "tblSales" has three fields: year, client and quantity. ... Sub ChangeWhereClause (ByVal Sender As System.Object, ... Imports System ... Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter ...
    (microsoft.public.dotnet.framework.windowsforms)