Introduction
In this tutorial, you'll build a web application that simulates an end-user finding a house they are interested in and submitting a form, which sends the details to a real estate agent by SMS.
A user interface of the application is shown below:
Lead submitted successfully
Note: The complete source code for this application can be found in our Vonage Community repo.
Note: The complete source code for this application can be found in our Vonage Community repo.
Prerequisites
Before you begin, make sure you have the following:
- Visual Studio 2026 (Community Edition or higher) with the ASP.NET and web development workload installed.
Visual Studio 2026 (Community Edition or higher) with the ASP.NET and web development workload installed.
- The .NET 10 SDK. It's included with Visual Studio 2026, or you can download it separately from Microsoft.
The .NET 10 SDK. It's included with Visual Studio 2026, or you can download it separately from Microsoft.
- A Vonage virtual number that can send SMS. You can rent one from the Vonage Dashboard under Numbers > Buy numbers.
A Vonage virtual number that can send SMS. You can rent one from the Vonage Dashboard under Numbers > Buy numbers.
- A mobile phone that can receive SMS, so you can test the app.
A mobile phone that can receive SMS, so you can test the app.
Note: If your account is still on trial credit, you can only send SMS to numbers you've verified in the Dashboard. If you're sending to US numbers, you may also need to complete 10DLC registration.
Note: If your account is still on trial credit, you can only send SMS to numbers you've verified in the Dashboard. If you're sending to US numbers, you may also need to complete 10DLC registration.
Getting Set Up
Create the Project
Begin by launching Visual Studio (Community Edition or higher) and selecting Create a New Project, and selecting ASP.NET Core Web App (Model-View-Controller) as shown below.
Create a new project in Visual StudioGive your project a name (example: SalesLead) and press Next.
For Framework, ensure it is set to .NET 10.0 (Long Term Support) and leave the other options as their default settings and press the Create button.
Configure your new projectChoose the .NET 10 frameworkIn Solution Explorer, right-click Dependencies and select Manage NuGet Packages.
Now select the Browse tab and search for Vonage.
You'll see Vonage appear and press Install on the latest stable release (8.35.0 at this time).
Install the Vonage NuGet package
Create a Vonage Application
We'll be sending our SMS with the Vonage Messages API which is Vonage's unified messaging API. The same code pattern works for SMS, MMS, WhatsApp, and more, so it's the recommended way to send messages going forward.
The Messages API authenticates with a Vonage Application ID and private key rather than an API key and secret.
Head over to the Vonage Dashboard and select Applications > Create a new application.
Give it a name (example: SalesLead), press Generate public and private key, and save the private.key file that downloads; we'll need it shortly.
Then toggle on the Messages capability (you can leave the webhook URLs pointing at a placeholder such as https://example.com/status for this tutorial) and press Generate new application.
Create a Vonage applicationFinally, link one of your Vonage virtual numbers to the application from the application's page. This is the number your SMS will be sent from.
Make a note of the Application ID as well.
Link a Vonage number to the applicationCopy the private.key file into the root of your project.
In Solution Explorer, select the file and set Copy to Output Directory to Copy if newer so the application can find it at runtime.
What Is MVC, and Why Should We Use It?
In short, MVC stands for model-view-controller, a design pattern that ensures applications are well architected and easy to test and maintain for future developers working in the code base.
- Models: Represent the data of the application.
Models: Represent the data of the application.
- Views: Represent the displayed HTML (or what the end user sees) of the running application.
Views: Represent the displayed HTML (or what the end user sees) of the running application.
- Controllers: Represent the Business Logic of the application.
Controllers: Represent the Business Logic of the application.
With a basic understanding of the pattern, let's build our application.
Begin With the Model (Data)
Right-click Models in Solution Explorer and Add a new Class. We'll give the name Lead.cs and press Add.
We'll add 4 pieces of information: The customer's name, phone number, the message they want to send as well as the result of submitting the form. This way, the end user knows if it was sent successfully or not.
Define the View (UI)
We will define the page that is presented to the end user now.
Select Views -> Home -> and then Index.cshtml.
Note: What is cshtml? It is a C# HTML file that is used on the server side by Razor Markup engine to render the webpage files to the user's browser.
Note: What is cshtml? It is a C# HTML file that is used on the server side by Razor Markup engine to render the webpage files to the user's browser.
We'll begin by defining the data model the template page will use, as shown in line #1 below. Next, we'll create a couple of divs so that our page looks nice once rendered (along with some boilerplate text about the house).
Then we'll use ASP.NET's BeginForm Extension method to easily construct a form. Several features are baked in, including an easy way to add Placeholder text and mark the field as required.
We'll wrap up with a button to submit the data (via a POST request) as well as a place to output if the SMS message was sent successfully or not.
For bonus points: Add a sample image of your house inside the project solution at the following location: wwwroot/Content/Images/house.jpg. :)
Add the Controller (Business Logic)
We need to store our Application ID and the path to our private key for our application to use when sending an SMS message. We'll place this inside a Domain class.
You can find your Application ID on the application's page in the Vonage Dashboard, and the private key is the private.key file we downloaded and copied into the project earlier.
Note: I added the secrets to this class for the ease of understanding the pattern. Please secure your secrets if you are publishing a production application using either environment variables or something such as Azure Key Vault.
Note: I added the secrets to this class for the ease of understanding the pattern. Please secure your secrets if you are publishing a production application using either environment variables or something such as Azure Key Vault.
Right-click the SalesLead project (not the solution) and add a new folder called Domain; inside that folder, create a new Class called Credentials.cs with the following content.
Next, we will write the logic that sends the SMS Message using the Messages API.
Select Controllers and then HomeController.cs and use the following code snippet. You'll need to update the using SalesLead.Models; to whatever the name of your project is in order to pull in your Model data.
When you run the code above and enter a Name, Phone Number and Message, the text message will be sent to the mobile number you specified (which, in this case, would be hard coded to the realtor's cell phone).
Below is the app after the form was submitted and the SMS was sent successfully!
Lead submitted successfully
Conclusion
In this tutorial, you built an ASP.NET Core MVC application with .NET 10 that collects a potential buyer's details through a web form and sends them to a real estate agent as an SMS using the Vonage Messages API.
Note: The complete source code for this application is on our Vonage Community repo.
Note: The complete source code for this application is on our Vonage Community repo.
Along the way, you created a Vonage Application, authenticated with an Application ID and private key, and saw how the model, view, and controller each handle their own part of the app.
The Messages API is multi-channel, so the same pattern you learned here can be extended to send MMS, WhatsApp, and more with only minor changes to the request object.












