Creating First HTTP Service using ASP.NET Web API: Part1 of Many

In this post I will give you basic understating of creating HTTP Services using ASP.NET Web API. Here I am assuming that you are aware of basic ASP.NET MVC.

To work with ASP.NET Web API, you need to install ASP.NET MVC 4.0. Download ASP.NET Web API from here and install it from Web Installer.

After installation create a new project choosing ASP.NET MVC 4 Web Application as project type.


Next choose Web API as template.


On examining project structure you will find it is exactly as usual ASP.NET MVC project structure. Let us go ahead and add a MODEL. For that right click on the Model folder and add a class. Let us add a model called Blogger


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace firstwebapiapplication.Models
public class Blogger
public int Id { get; set; }
public string Name { get; set; }
public string Intrest { get; set; }

After adding Model let us go ahead and add Controller. There are two differences between Controller of usual ASP.NET MVC Controller and ASP.NET Web API Controller.

  • ASP.NET Web API Controller returns data not view
  • ASP.NET Web API Controller is derived from ApiController class.

Now go ahead and add a Controller called BloggerController. For that right click on Controller folder and add a controller.


Choose Empty Controller as Scaffolding options.


Next you need to change the class controller is inheriting. Change Controller to ApiController.


Controller class needs to inherit ApiController class from System.Web.Http namespace. Let us add a function to return information about Bloggers.


using System.Collections.Generic;
using firstwebapiapplication.Models;
using System.Web.Http;

namespace firstwebapiapplication.Controllers
public class BloggersController : ApiController
// GET: /Bloggers/

public IEnumerable<Blogger> GetAllBloggers()
return new List<Blogger>
new Blogger(){ Id= 1,Name="DebugMode",Intrest="ASP.NET Web API"},
new Blogger(){ Id= 2,Name="KodefuGuru",Intrest ="C Sharp"},
new Blogger(){ Id= 3,Name="ActiveNick",Intrest = "Windows Phone" },
new Blogger(){ Id= 4,Name= "GBLOCK ", Intrest ="REST"},
new Blogger(){ Id= 5,Name = "WadeWegner",Intrest = "Windows Azure " }


By this point you have created HTTP Service. Press F5 to host the service on Cassini server.


And you will get a file to download


Next we can consume it in any client. In later post I will show you to consume in JavaScript client and Windows Phone as well. I hope this introductory blog post is useful to get started with ASP.NET Web API. In next post we will get into consuming ASP.NET WEB API Services in various clients


How to Create Bootable USB for Windows 8 Consumer Preview

In this post I will share screens to create Bootable USB for Windows 8 Consumer Preview.

Windows 8 Consumer Preview is available to Download

After downloading Windows 8 Consumer Preview you need to download

Windows 7 USB/DVD Download Tool

After downloading unzip and start running the setup. Follow the screens as below,




After installing makes sure that you have 4GB USB plugged in to the system.


Once Windows7 USB/DVD Download tool is installed open it


Browse to location where you downloaded ISO Image of Windows8 Consumer Preview


Follow the screens to copy ISO on bootable USB.



From dropdown choose the USB where you want to copy and select Begin Copying.


Choose option Erase USB Device.


Select option Yes



After successful copying you should be getting the below screen.


Now change boot setting in BIOS and make USB as primary booting device and start installing Windows 8 Consumer on your machine.