Rate this page:

Twilio Verify C# ASP.NET Core Quickstart

With just a few lines of code, your C# ASP.NET application can verify phone numbers and add an additional layer of security with Twilio Verify.

This C# Verify Quickstart will teach you how to do this using our Verify REST API, the Twilio C# helper library, and C# ASP.NET Core to ease development.

In this Quickstart, you will learn how to:

  1. Sign up for Twilio
  2. Set up your development environment to send and receive messages
  3. Send your first SMS phone verification
  4. Check verification codes

Sign up for Twilio

If you already have a Twilio account, you’re all set here! Feel free to jump to the next step.

Before you can send an SMS from C#, you'll need to sign up for a Twilio account or sign into your existing account.

You can sign up for a free Twilio trial account here.

  • When you sign up, you'll be asked to verify your personal phone number. This helps Twilio verify your identity and also allows you to send test verification messages to your phone from your Twilio account while in trial mode. This phone verification step is exactly what you'll learn how to build in this tutorial!
  • Once you verify your number, you'll be asked to create a project. For the sake of this tutorial, you can click on the "Learn and Explore" template. Give your project a name, or just click "skip remaining steps" to continue with the default.
  • Once you get through the project creation flow, you'll arrive at your project dashboard in the Twilio Console. This is where you'll be able to access your Account SID, authentication token, create a verification service, and more.

Do I need a phone number?

If you've sent SMS with Twilio in the past, you might remember needing to buy a phone number. With Twilio Verify, we take care of that for you! The Verify API selects the best routes for quickly and reliably delivering verification codes globally.

Now that you have a Twilio account and a verification service, you can start writing some code! To make things even easier we will use Twilio's official helper for C# and .NET applications.

Install .NET Core

If you’ve gone through one of our other .NET Core Quickstarts already and have .NET Core installed, you can skip this step and get straight to sending your first verification.

To start a phone verification and send your first SMS, you’ll need to have the .NET Core SDK installed - if you don't know if you have the .NET Core installed, run the following command to see what version you have:

dotnet --version

You should see something similar to this output:


The Twilio SDK requires .NET Framework version 3.5 or higher or any .NET runtime supporting .NET Standard v1.4.

If you have a not supported version of .NET Core or no .NET Core at all, you'll need to install the .NET Core SDK before going any further. Follow the directions for installing the .NET Core SDK for your platform (Windows, Mac, Linux) from the Microsoft .NET Download Page.

Should you prefer to use .NET Framework instead of .NET Core the instructions for building and running the project will be different and you will need to change the targeted framework. Besides that, the code should work straight away.

Clone and Setup the Verification Application

Start by cloning our C# ASP.NET Core repository.

git clone

If you don't have git installed or prefer to download the source code you can grab a zip file of the project here.

Install project dependencies

Twilio C# .NET Helper Library is already in the dependencies of the project. Building the project will download them.

cd verify-v2-quickstart-csharp/VerifyV2Quickstart/

dotnet build

Create a new file twilio.json and update the content. It will store your Twilio Account sensitive data. You can find your Account SID and Auth Token in the Twilio Console. Create a new Verification Service in the console and add the Verification SID to your twilio.json file.

  "Twilio": {
    "AccountSid": "Your Twilio Account SID",
    "AuthToken": "Your Twilio Auth Token",
    "VerificationSid": "Your Verify Service SID"

Run the application

dotnet ef database update

dotnet run

If your credentials are set up correctly you'll soon get a message that the app is up!

Use the .NET Core Twilio Verify Demo

Navigate to http://localhost:5000/Identity/Account/Register. You should see a registration form that looks like this:

sign up form with phone verification

Enter your phone number and choose which channel to request verification over. Finally hit the green Sign Up button and wait. You'll either receive a phone call or an SMS with the verification token. If you requested a phone call, as an additional security feature you may need to interact to proceed (the call will tell you to enter a number on the phone keypad).

Enter the token into the Verification entry form and click 'Verify':

verification entry form

And with that, your demo app is protected with Twilio's Phone Verification! You can now log out to try the untried channel.

What's Next?

Your demo app is now keeping fraudulent users from registering with your business and polluting your database. Next, check out all of the variables and options available to you in the Phone Verification API Reference. Also, to protect your customers in an ongoing manner (with this same codebase) try the C# .NET Core Authy Two-Factor Authentication Quickstart.

After that, visit the Docs for more Account Security demos and tutorials and web applications using all of Twilio's products.

Lastly, to protect your service against fraud, view our guidance on Preventing Toll Fraud when using Verify.

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.


        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more