ASP.NET 5: First Impressions


cloudraysI’ve been working on a new web site wholly using the ASP.NET 5 (e.g. vNext, MVC6, etc.) for the past couple of weeks. This means using Visual Studio 2015 Preview and the new project types in ASP.NET 5.

The idea around the site is to be an example of an ASP.NET 5 site using MVC6, EF7, and Visual Studio 2015. It’s not perfect and ASP.NET 5 isn’t ready yet so I expect to continue to fix and remove hacks for quite a while, but it’s been fun to dig into a whole new stack while it’s still getting the kinks worked out.  Here are some of my first impressions.

You can see the code as it progresses, I’m I’m not done yet, but I’m sharing the code I’m working on via GitHub here:

https://github.com/shawnwildermuth/MyCountries

One note of caution, this repo is really rough. Not README yet, not much in the way of comments. In the next week or so I’ll finish up the implementation and tiny up, but I wanted to share some thoughts on the new stack while they’re fresh in my mind. Let’s start with some background:

I’m coming to the new stack from where I’ve been using ASP.NET MVC and ASP.NET Web API as my primary web development stack. I also do a *lot* of client-side JavaScript and haven’t had to touch ASP.NET Web Forms for a very long time. Impressions are based on that experience, not yours.

If you’re going to play with the new stuff, some things to consider:

  1. Visual Studio 2015 Preview is just that. A preview. It can be quite slow at times but that’s to be expected at this stage in the game.
  2. The ASP.NET 5 stack is also a bit slow at this point. Don’t worry about it. I’m been told that it is purposeful. They haven’t optimized anything yet. Future versions will be a lot faster. Look at the features, not the performance at this point.

Ok, here are a list of impressions in no discernable order:

First of all, I love the direction of the new stack. It feels cleaner and less kludgy than ASP.NET’s configuration files, global.asax, and other hold overs from years gone by.

The .json based project configuration is compelling as I find it easier to use, but may be a learning curve to those not used to JSON. If you’ve played with Node.js you’ll see a lot that you’re comfortable with.

ASP.NET MVC 6 is very comfortable. New features are great, but the API is really similar and you’ll be up and running very quickly.

ASP.NET Web API is now inside of MVC 6 and very different. I am not a fan of the change. If you’re comfortable with the verb-based methods in Web API, you’ll have to revert to the attribute based verbs. I can see both sides of this. Many APIs aren’t publically surfaced, purely REST-based APIs. And for that the new direction is a big help. But if you’re building entity-style, verb rich APIs, you have more ceremony than you had with Web API. Luckily the routing and attributed routing are there so there is a comfort level with the stack. The merging of the two stacks (where you’re returning either views or data) is a good idea. They just moved my cheese and I don’t like it yet.

Entity Framework 7 is in a very early state right now. The code-first works as you’d expect but without eager or lazy loading implemented yet, you have to work around a lot of issues. Also, configuration of the contexts is pretty manual at the moment but that will all come around and I like the lighter API and the Async stuff a lot.

Getting used to the web root (e.g. wwwroot) in the project will take some time but worth the effort. Knowing what is exposed to the web and what isn’t is much clearer now and I like it.

The integration with Grunt (or in my case Gulp) to do some tasks for you is a great idea. The default Grunt task that copies all your Bower dependencies into the wwwroot works great to know what has to be shipped.

Once you get used to the different types of configuration, you’ll prefer it. The configuration system is very flexible (unlike the old one) so you can read all sorts of configurations, not have to shove everything into web.config and that gives us extra power to work with. But again, learning curve is required (though very shallow one).

Overall, I love the direction though it’s still early. Get the bits, play with them, and give them feedback. I’ve already had an item request on GitHub addressed and that’s a great feeling. You can look at all the source code and I even toyed with sending them a pull-request, but it ended up being larger than I had time so I didn’t do it.

It’s going to be a little painful to come to the new stack but I believe it will be worth it in the long run. It’s a shorter learning ramp than we had with Web Forms –> MVC so you should productive pretty quickly.

Once I’m done with the implementation, I’ll do a blog series on how I built it. Promise!

What do you think?




Application Name WilderBlog Environment Name Production
Application Ver 1.1.0.0 Runtime Framework .NETCoreApp,Version=v1.1
App Path D:\home\site\wwwroot Runtime Version .NET Core 4.6.24628.01
Operating System Microsoft Windows 6.2.9200 Runtime Arch X86