Where is MVC in Web API?

I am trying to get a hold on WebAPI so please excuse if the question is too naive to ask.

Been hearing that WebAPI is using MVC and is integrated in to it.

Just created a sample WebAPI project but under References I find not System.Web.Mvc dll.

Why? Or am I missing anything important?

EDIT:

About System.Web.Mvc, the MSDN says the following paragraph:

The System.Web.Mvc namespace contains classes and interfaces that support the ASP.NET Model View Controller (MVC) framework for creating Web applications. This namespace includes classes that represent controllers, controller factories, action results, views, partial view, model binders, and much more.

Upvotes: 2

Views: 1749

Answers (2)

Andrei
Andrei

Reputation: 56716

And it should not be there. ASP.NET Web API is very similar to MVC, buit is not integrated with it or whatever. Web API can live completely outside of MVC framework perfectly fine. Which is good - while building HTTP service you wouldn't want to include any HTML rendering features whatsoever into your project.

Think of it that way - System.Web.Mvc contains end-user-facing features that MVC uses, like views, view results. WebAPI is not a end-user-facing thing, it does not generate HTML or run javascript. Purpose of Web API is to provide means for creation of HTTP services - very different from MVC framework.

MVC and Web API share several similar approaches. Take controllers for example. Looks like they behave similar in both frameworks. However you may discover that implementations are different. MVC uses System.Web.Mvc.Controller, while Web API uses System.Web.Http.ApiController. More detailed explanation on the reason why is here. On the other hand - routing. Both frameworks use the same implementation of routing which resides in System.Web.Routing.

Frameworks are similar, but can exist completely separately. That is why there is no reference between them.

Upvotes: 4

rosko
rosko

Reputation: 474

For Visual Studio Express 2013 for Web do the following:

New Project > Web > ASP.NET Web Application > Web API > OK

This should work, the Add folders and core references for: MVC and Web API should be automatically ticked by VS.

100% working - I've just created a project and all the references are there.

Upvotes: 0

Related Questions