Web Api 2 Without MVC

Download full source code.

When building a Web Api 2 application there is much unneeded MVC baggage that comes along with it.

To start with all the css, html and javascript can go, then most of the packages, most of referenced dlls and almost all the C#.

Here are side by side comparisons of what you get and what you need.

All you really need for Web Api 2 is is the Global.asax to call WebApiConfig.Register which sets up the default routes and then a controller to perform an action.


public class WebApiApplication : System.Web.HttpApplication
    protected void Application_Start()


public static class WebApiConfig
    public static void Register(HttpConfiguration config)
        // Web API routes

            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }


public class ValuesController : ApiController
    // GET api/values
    public IEnumerable<string> Get()
        return new string[] {$"Guid 1: {Guid.NewGuid()}", $"Guid 2: {Guid.NewGuid()}" };

3 thoughts on “Web Api 2 Without MVC

Leave a Reply

Your email address will not be published. Required fields are marked *