A Minimalist WebAPI 2 Visual Studio Project

Introduction

Many of us have been asking Microsoft to keep all the extra stuff out of Visual Studio 2013 projects.  For example, I don’t want JQuery in my project yet almost all project types include it.  So, here are my steps to create just WebAPI 2 and no other types that are not directly that.

The Steps

File / New / Project

image

Empty Project with Just WebAPI

image

Then, when I go into References / Manage NuGet

image

I see just 4 packages

image

My Solution explorer is small and if I look in my App_Start, I just have one simple file, WebApiConfig.cs which is as follows:

image 

image

Project size, 29 files, 9 folders.   I’d say that’s pretty good.

About Peter Kellner

Peter is a software professional specializing in mobile and web technologies. He has also been a Microsoft MVP since 2007. In addition, he's a multi-course video author at Pluralsight. To read more about Peter Kellner and his experience click here. For information about how Peter Kellner might be able to help you with your project click here.

Follow me:


Comments

  1. Peter Kellner says:

    Also, not sure what you ended up with for WebAPI, but here is what my start looks like Peter.

    config.Routes.MapHttpRoute(
    name: “DefaultApi”,
    routeTemplate: “api/{controller}/{id}”,
    defaults: new { id = RouteParameter.Optional }
    );

    // Set the initializer here
    Database.SetInitializer(new SeDbInitializer());

    var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
    json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

    var jsonFormatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
    jsonFormatter.Indent = true;

    GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();

  2. Peter Kellner says:

    Yes, thanks. not sure how I got those pictures mixed up (fixed now). Good luck with your thesis and do post or contact me to let me know what you concluded. I’m currently doing an ExtJS Pluralsight video to go with my Sencha Touch video and I’m exclusively using WebAPI with EntityFramework 6 as my back end (All REST).

  3. Peter Nadasi says:

    Dear Peter K. ,
    I suppose that the last 2 pictures are not the ones you intended to show.

    To the topic:
    It’s great, as I sufferd from the VS2012 project in which the WEB API was the part of MVC and came with a lot of (in my case) rubbish (things I dont need, or I don’t know I need them).

    Something related personal:
    I’m currently writing a Thesis for my diploma, the topic contains WEB API and Ext.js together, so I’m watching your site updates curiously.

Follow

Get every new post delivered to your Inbox

Join other followers: