How to Get Advanced Number Insights Within an ASP.NET App
Published on May 13, 2021

This is the fourth article in a step-by-step series on how to use Nexmo's Number Insight API within an ASP.NET web application.

In the first article, we walked through everything we need to know about Number Insight API, setting up the ASP.NET application and getting ready to explore how to get insights about a phone number. In the second article, we covered Number Insight Basic API and how to use it. The third article was dedicated to Number Insight Standard API.

In this article, we will have a deep dive into Number Insight Advanced API.

Number Insight Advanced API is an easy-to-use RESTful web service. For any phone number you can:

  • Retrieve the international and local format.

  • Know the country where the number is registered.

  • Line type detection (mobile/landline/virtual number/premium/toll-free).

  • Detect mobile country code (MCC) and mobile network code (MNC).

  • Detect if number is ported.

  • Identify caller name (USA only) - see the CNAM guide for details.

  • Identify network when roaming.

  • Confirm user's IP address is in same location as their mobile phone.

Hands on code

In NumberInsightController.cs, let's start by creating the method that would allow the navigation to the advanced insights view.

public ActionResult Advanced()
   return View();

then add the view Advanced.cshtml to the NumberInsight views folder.

@using (Html.BeginForm("Advanced", "NumberInsight", FormMethod.Post))
    <input type="text" name="number" id="number" placeholder="Phone Number">
    <input type="submit" value="Get More Information">

This view will serve as a placeholder for the user to enter a phone number.

In order to get advanced insights about that phone number, we will add another method to 'NumberInsightController.cs' with a string parameter representing the phone number and make a call to Number Insight Advanced API.

public ActionResult Advanced(string number)
    var results = Client.NumberInsight.RequestAdvanced(new NumberInsight.NumberInsightRequest()
        Number = number,

    Session["requestID"] = results.RequestId;
    Session["iNumber"] = results.InternationalFormatNumber;
    Session["nNumber"] = results.NationalFormatNumber;
    Session["country"] = results.CallerName;
    Session["countryCode"] = results.CountryCode;
    Session["status"] = results.StatusMessage;

    if (results.OriginalCarrier != null)
        Session["originalCarrierName"] = results.OriginalCarrier.Name;
        Session["originalCarrierCode"] = results.OriginalCarrier.NetworkCode;
        Session["originalCarrierType"] = results.OriginalCarrier.NetworkType;
        Session["originalCarrierCountry"] = results.OriginalCarrier.Country;
    if (results.CurrentCarrier != null)

        Session["currentCarrierName"] = results.CurrentCarrier.Name;
        Session["currentCarrierCode"] = results.CurrentCarrier.NetworkCode;
        Session["currentCarrierType"] = results.CurrentCarrier.NetworkType;
        Session["currentCarrierCountry"] = results.CurrentCarrier.Country;

    Session["validNumber"] = results.NumberValidity;
    Session["ported"] = results.PortedStatus;
    Session["reachable"] = results.NumberReachability;
    Session["roaming"] = results.RoamingInformation.status;

    return RedirectToAction("AdvancedResults");

Notice that after fetching the insights, we need to publish them to the user. We are going to create an AdvancedResults method in the controller and a AdvancedResults.cshtml view for that matter.

public ActionResult AdvancedResults()
    ViewBag.requestID = Session["requestID"];
    ViewBag.iNumber = Session["iNumber"];
    ViewBag.nNumber = Session["nNumber"];
    ViewBag.status = Session["status"]; = Session["country"];
    ViewBag.countryCode = Session["countryCode"];
    ViewBag.currentCarrierName = Session["currentCarrierName"];
    ViewBag.currentCarrierCode = Session["currentCarrierCode"];
    ViewBag.currentCarrierType = Session["currentCarrierType"];
    ViewBag.currentCarrierCountry = Session["currentCarrierCountry"];
    ViewBag.originalCarrierName = Session["originalCarrierName"];
    ViewBag.originalCarrierCode = Session["originalCarrierCode"];
    ViewBag.originalCarrierType = Session["originalCarrierType"];
    ViewBag.originalCarrierCountry = Session["originalCarrierCountry"];
    ViewBag.validNumber = Session["validNumber"];
    ViewBag.ported = Session["ported"];
    ViewBag.reachable = Session["reachable"];
    ViewBag.roaming = Session["roaming"];

    return View();
    <h1>Number Insight Advanced Results</h1>
        <hr style="height:2px; color:black">
        <h2>Request ID: @ViewBag.requestID</h2>
        <h2>Status: @ViewBag.status</h2>
        <hr style="border:2px solid black">
        <h2>International Number: @ViewBag.iNumber</h2>
        <h2>National Number: @ViewBag.nNumber</h2>
        <h2>Country Code: @ViewBag.countryCode</h2>
        <hr style="border:2px solid black">
        <h2>Current Carrier Name: @ViewBag.currentCarrierName</h2>
        <h2>Current Carrier Code: @ViewBag.currentCarrierCode</h2>
        <h2>Current Carrier Type: @ViewBag.currentCarrierType</h2>
        <h2>Current Carrier Country: @ViewBag.currentCarrierCountry</h2>
        <hr style="border:2px solid black">
        <h2>Original Carrier Name: @ViewBag.originalCarrierName</h2>
        <h2>Original Carrier Code: @ViewBag.originalCarrierCode</h2>
        <h2>Original Carrier Type: @ViewBag.originalCarrierType</h2>
        <h2>Original Carrier Country: @ViewBag.originalCarrierCountry</h2>
        <hr style="border:2px solid black">
        <h2>Number Validity: @ViewBag.validNumber</h2>
        <h2>Number Portability: @ViewBag.ported</h2>
        <h2>Number Reachability: @ViewBag.reachable</h2>
        <h2>Roaming Information: @ViewBag.roaming</h2>

Now, let's run the app and make a call to Number Insight advanced API. You can use one of the Nexmo numbers provided for testing.

Advanced Number Insight GIFAdvanced Number Insight GIF


In this article, we learnt how to use Nexmo’s Number Insight Advanced API to retrieve advanced insights about a phone number. Then we showed this information on a view within an ASP.NET application.

Nexmo Number Insight getting started guide for ASP.NET

Rabeb OthmaniVonage Alumni

Rabeb was a Developer Advocate at Nexmo focusing on cloud communication APIs and helping developers get the best experience possible when building their apps. Other than writing code for a living, Rabeb advocates for bringing more women and minorities into tech, thus her involvement with Women Who Code and different tech communities. She leads the Women Who Code Network in Bristol.

Ready to start building?

Experience seamless connectivity, real-time messaging, and crystal-clear voice and video calls-all at your fingertips.

Subscribe to Our Developer Newsletter

Subscribe to our monthly newsletter to receive our latest updates on tutorials, releases, and events. No spam.