Tag Archives: web api

Application Insights Intrumentation Key in Web.config

When using Azure Application Insights in ASP.Net application, by default, Visual Studio insert IntrumentationKey in ApplicationInsights.config.

To allow multiple environments tracking, move IntrumentationKey to Web.config by following this steps:

  1. Remove IntrumentationKey from ApplicationInsights.config. If you have MVC application, don’t forget to modify ApplicationInsights’ script (usually in View\Shared\_Layout.cshtml), replace:

    {instrumentationKey:"your instrumentation key"}


  2. Add new app settings for IntrumentationKey in Web.config under <appSettings>

    <add key="InstrumentationKey" value="your instrumentation key" />
  3. In Global.asax.cs, Application_Start() method, add:

    Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = System.Web.Configuration.WebConfigurationManager.AppSettings["InstrumentationKey"];

That’s it for the configuration changes. Everything else is the same including tracking custom event or page view.
With this configuration, you will be able to define InstrumentationKey in Release management for each environments.

Leave a comment

Posted by on May 18, 2018 in General


Tags: , , , , , ,

ASP.Net Web API Pipeline

Similar to ASP.Net MVC but not exactly the same. Pedro Felix has this self-explanatory graph depicting ASP.Net Web API


Head over to the full article, ASP.Net Web API Processing Architecture 

Leave a comment

Posted by on June 1, 2015 in General


Tags: ,

Claims-Based Authorization in ASP.Net MVC and Web Api

Normally, I would re-write a blog post in hope to provide better explanation and concise the article, but since this is from Dominick Baier, I think he does it the best.

So, here’s it, how to apply claims based authorization in ASP.Net MVC and Web Api:

Leave a comment

Posted by on May 28, 2015 in General


Tags: , , , , ,

Dependency Injection in Web API With Unity IoC


public static class WebApiConfig
    public static void Register(HttpConfiguration config)
        var container = new UnityContainer();
        container.RegisterType<IProductRepository, ProductRepository>();
        config.DependencyResolver = new UnityResolver(container);

        // Other Web API configuration not shown.


protected void Application_Start()
    // Some code here...


    // Some code here...

Version attow: Unity 3, Web API 2

Leave a comment

Posted by on November 18, 2014 in General


Tags: , , ,

Learning Paths

With so many tutorials, articles and resources available out there on the Internet, learning new programming language, framework and library become much more easier. However, as much as its advantage, readily available resources have also become its own problem: where should I start?

With so many options available, it can be confusing to even start learning. I present you my learning paths to solve this problem. Learning paths will guide you through learning programs for each subject of your interests. Think of this as a curriculum to the degree you want to get.

Most of the courses are from, but this learning paths are not limited to just I also include some free courses from other sources. While I understand that you may have to pay for some of these courses, I can assure you that paying the subscription is worth it (especially Pluralsight!).

I will update this learning paths to include more subjects and courses in the future. Stay tuned!


Level Course
0100 Get the Android SDK (
0101 Prerequisite: 0100
Getting Started (
0102 Introduction to Android Development (
0200 Prerequisite: 0101 or 0102
Android Async Programming and Services (


Level Course
0100 AngularJS Fundamentals (
0200 Prerequisite: 0100
AngularJS In-Depth (
0201 Prerequisite: 0100
Testing AngularJS From Scratch (


Level Course
0100 ASP.NET MVC Fundamentals (
0200 Prerequisite: 0100
ASP.NET MVC 5 Fundamentals (


Level Course
0100 Introduction to the ASP.NET Web API (
0200 Prerequisite: 0100
Web API v2 Security (
0201 Prerequisite: 0100
Web API Design (


Level Course
0100 C# Basic (
0101 C# From Scratch (
0102 Prerequisite: 0101
C# From Scratch – Part 2 (
0200 Prerequisite: 0100 or 0102
Object-Oriented Programming Fundamentals in C# (

Entity Framework

Level Course
0100 Getting Started with Entity Framework 5 (
0200 Prerequisite: 0100
Entity Framework Code First Migrations (

JavaScript & jQuery

Level Course
0100 W3Schools’s JavaScript Tutorial (
0101 JavaScript Fundamentals (
0120 Prerequisite: 0100 or 0101
DO Factory’s JavaScript + jQuery Design Pattern Framework – JavaScript & Pattern Essentials (
0200 Prerequisite: 0100 or 0101
JavaScript Design Patterns (
0300 Prerequisite: 0200
jQuery Fundamentals (

WIF, Claims-based Identity, OAuth2

Level Course
0100 Introduction to Identity and Access Control in .NET 4.5 (
0200 Prerequisite: 0100
Identity and Access Control in ASP.NET 4.5 (
0201 Prerequisite: 0100
Identity and Access Control in WCF 4.5 (
0202 Prerequisite: 0100
Web API v2 Security (
0300 Prerequisite: 0200 or 0201 or 0202
Introduction to OAuth2, OpenID Connect and JSON Web Tokens (JWT) (
1 Comment

Posted by on September 15, 2014 in General


Tags: , , , , , , , , , , ,

ASP.NET Web API and OData’s Verbose JSON

OData v3 and Verbose JSON

Whenever you work with OData in ASP.NET Web API, the return result will be JSON format. It’s noteworthy to know that by default Web API will return new OData JSON format specified in OData version 3. For older OData, the JSON format is different. It has more ‘unnecessary’ placeholders. This old OData JSON is also referred as ‘Verbose JSON’. In short, there are two types of OData JSON:

  • OData v3 has new JSON format
  • Verbose JSON is used in older OData versions.

ASP.NET Web API (.Net 4.5) and Verbose JSON

As mentioned before, by default Web API will return new OData JSON.

To change this behavior, you can request Web API to return old OData JSON format by specifying ‘odata=verbose’ in Accept header. Below is the sample of jQuery Ajax call specifying verbose JSON:

    url: "/api/Products",
    dataType: "json",
    accepts: { json: "application/json;odata=verbose" }
}).done(function() {
    // do work ...

How it Looks Like?

For the curious:

Verbose JSON

    "d" : {
        "results": [
                "__metadata": {
                    "uri": "http://demos/Orders(10248)",
                    "type": "SampleModel.Order"
                "ProductId": 10248,
                "Name": "Vgnon"
        "__count": "1"

OData v3 (and above) JSON

Leave a comment

Posted by on October 7, 2013 in General


Tags: , ,

Differences Between WCF and Web API

There are good reasons to use ASP.Net Web API instead of WCF. But, what are the differences?

Support SOAP and REST. Support only REST.
Protocols supported: TCP, HTTP, HTTPS, Named Pipes, MSMQ. Only HTTP / HTTPS protocols are supported. It uses full-feature of HTTP (URIs, request / response headers, caching, content formate, etc)
Data formats supported: XML, JSON, ATOM. Data formats supported are typically JSON and XML. But can be extended with Web API’s MediaTypeFormatter.
Required extensive configurations. Very little configurations. Development is similar to coding in ASP.Net MVC.
Passing parameters to WCF operations need configurations and must be specified in UriTemplate. Parameters are bound automatically, similar to ASP.Net MVC Model Binding feature.
Web API’s URI is by convention (controller / action name).
HTTP verbs supported: GET, POST. Other verbs are supported with more IIS configurations. Support full HTTP verbs. GET, POST, PUT, DELETE, PATCH, HEAD, etc.
Can be hosted on IIS, Windows Service, or with in a web application. Can be hosted on IIS or with in a web application.
WCF is bigger framework, allowing full customization, such as SOAP, REST or WS-*. To support MVC features, it requires heavy customization and configuration. Supports the MVC features such as routing, controllers, action results, filter, model binders, IOC container or dependency injection, unit testing.

More reading about Web Service, WCF, WCF REST, Web API.

Leave a comment

Posted by on April 23, 2013 in General


Tags: , , ,

%d bloggers like this: