Wow, time flies when work is keeping you extra busy. I haven't done a lot of work on POP Forums in a few months. Fortunately, there's something new to talk about.
As ASP.NET 5 is now in its final beta (8!) before the first RC, I figured now would be a good time to be a bit more serious about understanding it. As excited as I am about it, it's starting to feel clear to me that it's not something that you're going to be that anxious to port existing apps to. It's very different, and it breaks a lot of things. Naturally, my first attempt at understanding it is to port the forum app, because nothing says real life like, uh, a real app. Doing greenfield work is going to go a lot more smoothly, that's for sure.
In any case, after spending a few evenings with it here and there, here are some of my initial impressions:
- Adopting the OWIN pipeline model makes a lot of sense, and I don't think anyone is really going to miss the event model of the previous ASP.NET. HttpHandlers were already made largely obsolete by MVC, and middleware takes the place of HttpModules.
- System.Web is gone, but the things that it did can be found in a number of other places. You just have to look around. Sometimes, a lot.
- With FormsAuthentication going away (as best as I can tell) in favor of claims-based auth, all of the samples you find depend on Identity. This annoys me to no end. Remember the Membership API? It was awful. Identity is better, but it still tries to be everything to everyone, and in the end, I'm not generally interested in using it, or writing my own replacement for the EF provider. I'd like code samples and docs that cut through the magic of the middleware and let me do what I want with the claims (especially for the 3rd party auth).
- You will encounter strangely broken things. For example, data readers apparently now make the Close() method private. It will get called when you Dispose().
- Did you use HttpRuntime.Cache back in the day? Me too. It's the reason why the forum is so fast. Unfortunately, you can't do that in multi-node web apps, but if you want to, there is an in-memory cache package, as well as one for Redis. That's awesome.
- Dependency injection is built in, and that's cool and all, but obviously I have no idea how good it is. I'm a big fan of StructureMap, but for now I'm using the built-in containers, which you have to manually configure. That's why I love SM... the convention-based config.
- It sure seems like you can package an entire app or area as a NuGet package. I have no idea how, but it's something I'm already thinking about.
- Old school resx files for resources work, but it's apparently not the way going forward. I haven't read up on it, but hope it's not a huge change.
- The new configuration scheme is so much better than the old, and infinitely more flexible. Sure, you should still be building strongly typed wrappers around your configuration, but using JSON over XML is very nice.
- ViewComponents and tag helpers are a great evolution when it comes to chunking out pieces of UI. Remember how you would typically have to get everything in your model (or ViewBag, puke) that you might want to display? VC's get around that. They're especially excellent for layout pages, and they come with all of the DI magic.
- Speaking of which, you can inject services right into a view now. I know, academically you probably think that's a bad idea, but I've always had a great use case: formatting dates/times based on the user's time zone. I've never liked formatting somewhere upstream and sending it down as part of the view model. Now I don't have to.
There's a lot to learn, but I'm pretty enthusiastic about where we're headed. I've got a ton of refactoring in front of me for the forum app, but I suspect the new frameworks will help me a great deal in making the app easier to deploy and integrate.