none
Open Web Page by Posting data from windows application RRS feed

  • Question

  • Hi,

    I am using visual basic 2003 windows application. I have one button, where when I click the button it should open api webpage using the url and send the parameters. I have written the code in 2017 visual basic with no issues. But I cant write the same code in 2003 because Newston.Json and system.http is not available. I cant do the serialization. Can someone help me? Below is my code in 2017 vb. The bolded part is where i get the error in 2003

    Imports Newtonsoft.Json
    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Net.Http
    Imports System.Text
    Imports System.Threading.Tasks
    Imports System.Web
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Public Class test2
        Inherits System.Web.UI.Page

        Private Async Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

            Dim paras As PointPara = New PointPara
            paras.membercode = "701111071111"
            paras.Amount = "20"

            Dim Result = Await DeductBalance(paras)

        End Sub

        Public Class PointPara
            Private _membercode As String
            Private _Amount As String
            Public Property membercode As String

                Get
                    Return _membercode
                End Get
                Set(VALUE As String)
                    _membercode = VALUE
                End Set
            End Property

            Public Property Amount As String
                Get
                    Return _Amount

                End Get
                Set(value As String)
                    _Amount = value
                End Set
            End Property
        End Class

        Public Async Function DeductBalance(ByVal para As PointPara) As Task(Of String)
            Dim AgentPostURL As String = "http://themeparkv1.azurewebsites.net/themepark/api/Point/CreditDeduct"
            Dim client As HttpClient = New HttpClient
            '= await GetClient(  PostURL, ParentNRIC);
            Dim jsonstringSend = JsonConvert.SerializeObject(para)
            Dim response = Await client.PostAsync(AgentPostURL, New StringContent(jsonstringSend, Encoding.UTF8, "application/json"))
            Return Await  response.Content.ReadAsStringAsync
        End Function
    End Class

    Monday, October 8, 2018 6:11 AM

All replies

  • Hi,

    According to your description, your issue is more related about asp.net. And this forum is discussing and asking

    questions about the vb.net.

    Ask in the following forum.

    https://forums.asp.net/

    Thank you for your understanding.

    Thank you for participating in the forum activities.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 8, 2018 8:20 AM