I’ve let this little fact out on Twitter, so here’s a little more detail on why I’m not going to be working on Simple.Web any more.
Original motivation
Whenever people asked why I wrote Simple.Web, I would reply “because Microsoft broke Web API”. Eventually, at an MVP Summit, Scott Hanselman had me stand in front of the Web API development team and explain what it was that they had broken, which was… awkward.
I started writing Zudio when Web API was still “WCF Web API”, being developed by Glenn Block. I think I was using version 0.6. The project had gone quiet, then suddenly re-emerged as ASP.NET Web API 1.0 beta. I switched to the new framework, and everything broke. They’d changed the way IoC/DI worked, they’d added an ApiController base class, and they’d taken out the attribute-based routing, which I’d been a huge fan of.
Here’s the thing about routing. When I create an API, web or otherwise, it is rarely of the type popularised by Ruby on Rails, ASP.NET MVC and most other MVC frameworks. These tend to think of an API as simple resources with HTTP methods – two GETs, a POST, a PUT and a DELETE. That’s not an API. That’s just a basic Data Access Layer over HTTP. Sure, I’ve written code where that is a valid pattern for certain resources, but it’s not an API. An API provides high-level commands and operations, such as “activate this user” or “complete this order”.
The ASP.NET Web API 1.0 release offered the same routing as ASP.NET MVC – “{controller}/{action}/{id}” – and if you wanted anything more complicated, you had to manipulate the routing table directly.
So, I took all the things that I had liked about WCF Web API and put them into Simple.Web. I also added a feature of my own, inspired by a talk I’d seen that week about “Hypermedia As The Engine Of Application State”, where the serialization process would include collections of links so that API consumers didn’t have to hard-code URLs.
Simple.Web also removed the distinction between Views and other types of result, honoured Accept headers, promoted a “Single-Action Controller” pattern, and had a completely asynchronous pipeline.
What’s changed?
Well for a start, Web API 2 has attribute based routing. And it’s got a class-level RoutePrefix attribute that lets you apply routing to a controller; if you then just have a single method (say, “Get”) with an empty Route parameter, you’ve essentially got Simple.Web’s Single-Action Controller pattern.
Web API also has a comprehensive set of hooks and providers and what-have-you that mean you can extend or modify any functionality you like (or don’t like). So the couple of tricks that Simple.Web did, like the link generation, are easy to add in.
And then there’s OWIN, which allows you to integrate functionality into your Web API application at the pipeline level without faffing around with System.Web HttpModules and the like.
Also, Microsoft have changed. Certainly DevDiv. There’s a bunch of awesome people working there, who have been pushing hard for open source ideals across the entire stack, and it’s working. Most of the ASP.NET stack – certainly all the bits I care about – are now developed in the open, and ASP.NET vNext is on GitHub, and accepting pull requests.
ASP.NET vNext was the real trigger, in the end. I am incredibly excited about what’s going on there. A completely new, very lightweight CLR, a modularised base class library distributed via NuGet (just like I asked for), and MVC and Web API combined into a single, cohesive framework. With, incidentally, a fully asynchronous pipeline.
(David Fowler and Damien Edwards were in my Simple.Web talk at NDC London last year. Just sayin’.)
Simple.Web scratched an itch that I had. There is fundamentally no point continuing to scratch an itch that doesn’t itch any more, especially when there’s an over-the-counter cream [metaphor terminated due to potential taste boundary violation].
Seriously, though, I’ve got limited time, and when a mainstream product does everything I need, the way I want it, then I should spend that time creating value instead of replicating other people’s efforts*.
What now, then?
Well, I’m migrating Zudio over to MVC 5.2 & Web API 2.2, which is actually much easier than I expected, and I’ll upgrade that to vNext as soon as there’s a stable release with good performance that I can confidently run on Azure Web Sites.
My AngularJS client-side code relies heavily on the hypermedia links that Simple.Web generates, so I’ve implemented that part of Simple.Web as a Web API extension called Linky, which is on GitHub now and NuGet soon. As and when I find other gaps in Web API or MVC, I will fill them with more extensions. It is my fond hope that simple extensions to the canonical frameworks might be more useful to the wider community than full-blown alternatives.
I will also be doing some blogging (on my coming-soon new blog) about Web API extensions I’ve written that are specific to my project, but where the patterns are broadly applicable.
Finally, I can get back to working on Simple.Data v2 (assuming that Entity Framework v7 isn’t going to add dynamic method-name-based operations).
*PostScript
Just to be clear, this doesn’t mean that I think all alternative web frameworks are a waste of time. Those that offer a completely different approach and philosophy, such as Nancy, obviously bring much-needed innovation and value to the .NET ecosystem. It’s just that Simple.Web doesn’t any more.