.NET posts

There are a lot — really a lot — of applications collecting phone numbers. Those numbers all need to be validated and verified. It makes sense to do some of the validation on the front end where an end user or customer service agent can correct errors without waiting on a round trip to a server.
Application front-ends can determine if the contents of a specific field are “phone number-ish” by using data types, regular expressions, input masks, and odd bits of JavaScript. But they can’t tell if the input is a real phone number without checking the input against a list of real phone numbers.
Twilio Lookup makes it easy to validate phone numbers for both web applications and applications developed with .NET Core Windows Presentation Foundation (WPF), an open-source UI framework for creating desktop client applications for Windows.
Twilio provides helper libraries for a variety of programming languages …

Xamarin is a powerful tool for building cross platform apps for Android and iOS devices. You can use Xamarin without leaving the comfort of your Visual Studio development environment and you don’t have to buy and connect a bunch of mobile phones to test your apps: Xamarin includes emulators to give you a real feel for how your user interface will look and work.
One of the time-saving and powerful aspects of Xamarin is Xamarin.Forms, a toolkit for building user interfaces with eXtensible Application Markup Language (XAML) to define how a user interface component in a Xamarin app will look and behave. Xamarin XAML (try saying that five times fast) works in concert with code-behind C# classes, a structure you may be familiar with if you’ve worked with ASP.NET or ASP.NET Core.
Xamarin.Forms includes Data Binding, a way of keeping a user interface synchronized with its underlying data without …

Testing your C# code is important, and it’s even more important when your code relies on external services. Writing tests will not only help you catch bugs, it will help you write better code by thinking about factors that affect the structure and resilience of your software.
Visual Studio 2019 includes some great tools for creating and running unit tests, and you can put them to work without a lot of setup or configuration. Whether you’re writing a new app or trying to improve a brownfield program, it’s easy to integrate unit testing into your workflow.
Twilio understands the importance of testing and provides resources for you to use when you’re creating unit tests for code that interacts with Twilio products, like Programmable SMS. To show you how easy it is to get started, this post will walk you through the process of building and testing a .NET Core console …

Dropdown lists are one of the most widely used user interface controls. It’s also common for the options presented in a dropdown to depend on the value of another control. Finding a good way to build this functionality is a challenge developers often face when beginning to build websites with ASP.NET Core.
You can build hierarchical dropdown lists using ASP.NET Core Razor Pages using an Ajax call on the page view and an action method on the page model. It doesn’t require writing a lot of code, and the technique can be applied in numerous situations where user interface data needs to be set dynamically. No JavaScript frameworks required!
Using Razor Pages with the Model-View-ViewModel (MVVM) design pattern provides a way of separating the presentation of data in the Razor Page, the view, from the structure of the data that is presented and manipulated by business logic, the view model. …

Another conference call, another app, another PIN, another log-in. Joining conference calls should be as simple as dialing a phone number, without needing to enter random conference IDs. In this post, we will walk through how you can build a conference line that anyone can join, using Twilio with C# and ASP.NET Core.
Developer Environment Setup
Let's make sure you have the software you need to build this conference line. For this, you will need:
Create the ASP.NET Core Project
Get started by creating a folder for your project. I'll be using C:\Code\Conference
in this post but you can use your preferred project path. Open a command prompt and enter the following commands.
mkdir C:\Code\Conference & cd C:\Code\Conference
dotnet new webapi
dotnet add package Twilio
code .
exit
It will create …

Who’s calling? In the era of ubiquitous mobile phone use it’s almost impossible to identify the name associated with a phone number unless you’ve already made that connection in your smartphone’s contact list, an annoyance facilitating “New phone who dis?” memes.
But it’s still possible to get the caller name associated with a telephone number, and you can do it without waiting for a call. Twilio Lookup and the Twilio Helper Library for .NET make it easy to integrate real-time caller information retrieval into web applications built with ASP.NET Core.
Understanding “Caller ID” information
The history of “Caller ID,” as it’s commonly known, is surprisingly complex and has involved a number of standards, protocols, and technologies. While the various systems referred to as Caller ID make it possible to identify a calling number, a caller’s name is provided through a system known as Calling Name Presentation (CNAP) …

One of my favourite features of Azure Functions v2 and above is the ability to include a Startup
class. Why is this cool you may ask? Well, it means that you can use .NET Core's built-in Dependency Injection (DI). This then means that project architecture can look remarkably like ASP.NET Core web apps. DI also makes testing easier as dependencies can be mocked. In this post, I'll show you how you can quickly add DI to an Azure Function.
Note: Azure Functions v3.0 became GA in January 2020. This means that you can now use .NET 3.1 and Node 12 in your Azure Functions. They still don't support the newSystem.Text.Json
but that should come in time.
If you would like to see a full integration of Twilio APIs in a .NET Core application then checkout this free 5-part video series I created. It's separate from this blog post tutorial …

Data validation is an essential part of application design and development, and telephone numbers are as tricky to validate as they are ubiquitous. In many cases a phone number will be the primary way your organization communicates with its customers. Whether the communication will be by voice, SMS, or messaging app, having a correct phone number is a requirement.
Developers using .NET Core and the .NET Framework can do validation for a number of different data types, including phone numbers, with the System.ComponentModel.DataAnnotations namespace, but the PhoneAttribute class has its limitations. To learn more, see the .NET Data Validation section of the previous Twilio Blog post on this subject: Validating phone numbers effectively with C# and the .NET frameworks.
Fortunately, the libphonenumber-csharp open source library provides extensive resources for validating and manipulating phone numbers of all types and it’s conveniently available as a NuGet package. This post shows …

This blog post is part of The Third Annual C# Advent by Matthew Groves which is a C# advent calendar.
Do you worry you're stuck on the naughty list? Have you forgotten all the good deeds and awesome things you've done over the past year to deserve more than a sack of coal?
Tracking your little wins as they happen is a fantastic way to remember your successes whether you're sharing the list with your boss or Santa Claus or just yourself!
We will use Twilio Autopilot to capture your accomplishments, thus enabling you to keep a log via SMS, voice, WhatsApp, Slack or even your Amazon Alexa or Google Home device!
We're going to save the output of Autopilot to Azure Table Storage via an Azure Function.
This post assumes some basic knowledge of C# and RESTful APIs.
To get started, we will need:
- A Twilio account
- An Azure …

If you have a bit of familiarity with Polly, the resilience framework for .NET, you will know how useful the Retry and Wait and Retry policies are for handling transient faults and longer outages. But there are times when no amount of retries will solve the problem, the remote system is unresponsive, has been for a while and will likely continue to be so. In this scenario, cutting the connection to the failing system might be the best approach.
Polly lets you do this with its Circuit Breaker policies. The policies get their name from the circuit breaker in your home that cuts electricity to an outlet or fixture. Just like the real-world circuit breaker, the Polly Circuit Breakers cut your connection to a faulting system.
This post shows you how to incorporate Polly Circuit Breakers into your resilience strategy. You’ll build working examples with ASP.NET Core 2.1 and see …