ASP.net code example

ViaNett provides you with code examples and programming objects, to help you connect to our gateway using the programming language of your choice. You are welcome to try these scripts. Sign up now to get 5 free SMS.

What is ASP.net?

Microsoft ASP.NET is a web application framework enabling programmers to build dynamic web sites, web applications and web services. Read more at Wikipedia or on the official home page.

ASP.net VB example

This example code uses a ready-made object, based on the HTTP API. To use this script, simply register for free and get 5 free SMS.

        Dim s As New ViaNettSMS(username:="YourUsername", password:="YourPassword")
        Dim result As ViaNettSMS.Result
        Try
            result = s.sendSMS(msgsender:="4790000000", destinationaddr:="4790000000", message:="hello world")
 
            If result.Success Then
                Response.Write("Message successfully sent")
            Else
                Response.Write("Received error:" & result.ErrorCode & " " & result.ErrorMessage)
            End If
 
        Catch ex As System.Net.WebException
            'Error occurred while connecting to server.
            Response.Write(ex.Message)
        End Try

ASP.net C# example

This example code uses a ready-made object, based on the HTTP API. To use this script, simply register for free and get 5 free SMS.

        string username = "username";
        string password = "password";
        string msgsender = "4790000000";
        string destinationaddr = "4790000000";
        string message = "hello world";
        
        ViaNettSMS s = new ViaNettSMS(username, password);
        ViaNettSMS.Result result;
        try
        {
            result = s.sendSMS(msgsender, destinationaddr, message);
            if (result.Success)
            {
                response.Write("Message successfully sent");
            }
            else
            {
                response.Write("Received error:" + result.ErrorCode + " " + result.ErrorMessage);
            }
        }
        catch (System.Net.WebException ex)
        {
            //Error occurred while connecting to server.
            response.Write(ex.Message);
        }

"ViaNettSMS" object

ViaNett provides you with an object/class written in VB.net or C#, based on the HTTP API. The source code is available for download at the VB.net code example page or the C# code example page.