Here we will create simple Web API Application using MVC 4 with Razor
What is Web API?
From msdn, ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
When to use Web API?
- Web API when you want to create a resource based services over HTTP that can use the full features of HTTP (like URIs, request/response headers,various content formats).
- Use Web API when we want to expand service at wide way like mobile,browser,tablet…
- If we need a Web Service and without using SOAP, then ASP.Net Web API is best choice.
why we use Web API ?
WCF gives you the flexibility to use other protocols, but the REST implementation is a bit more complicated when compare to Web API
For Detail about REST , Go here
Step : 1
Create new project -> choose MVC Web Application and click ok
Step : 2
Next, in project template choose Web API and click ok
Step : 3
Open Values controller (which was created in default for Web API) ie., ValuesController
public class ValuesController : ApiController
// GET api/values
public IEnumerable<string> Get()
return new string