Create a Simple WEB API Project

Select a Project

Start Visual Studio 2015. From the File menu, select New > Project. In the New Project Template, select Web > .NET Framework 4.6 > ASP.NET Web Application.

web api

Name the project “FirstWebAPI”, browse and choose a location and click OK. Also check “Application Insights” and Send telemetry to “New Application Insights resource”. We will discuss Application Insights functionality in the near future separately.

Select a Template

Select the template ASP.NET 5 Empty and click Ok.

The first Web API solution is created.

empty template

The default solution structure is created as in the following:

default solution

Build and execute it. There could be an error message as in the following:

HTTP Error 403.14 - Forbidden

The Web server is configured to not list the contents of this directory.

Enable directory browsing using the appcmd.exe tool. It is a two-step process.

  1. Go to the IIS Express install directory (in other words C:\Program Files (x86)\IIS Express).

  2. Run appcmd set config /section:system.webServer/directoryBrowse /enabled:true

Complete Employee API

Find the attached FirstWebAPI solution for implementation. The Employee controller implements some basic CRUD operations.

How to invoke endpoints

A HTTP request can be passed using any a REST Client (Fiddler, SOAPUI, Chrome client and so on). An example request and response as in the following:

GET - http://localhost:1117/api/emp

Request Header

Content-Type: application/json

Output