Routing in Web API

In article we will see how ASP.NET Web API routes HTTP requests to controllers. Web API routing is very similar to MVC routing. The main difference is that Web API uses the HTTP method, not the URI path, to select the action. We can also use MVC-style routing in Web API. A related difference is that Web API performs content type negotiation in response to incoming requests, and attempts to return the proper content type.

Web API route Configuration file

In a standard Web API project template, route configuration is called from  RouteConfig class, and a WebApiConfig class, both in the App_Start folder.

Continue reading

Extension Method in C#

Introduction

Extension methods are a introduced in C# 3.0. An extension method enables us to add methods to existing types without creating a new derived type, recompiling, or modify the original types. An extension method is a static method to the existing static class. We call an extension method in the same general way, there is no difference in calling.

Continue reading