What's In the Box with ASP.NET MVC 4?
There are a few new things that come with new projects build in ASP.NET MVC 4 along with the ones we are used to by now. These tools that you get are delivered via NuGet packages, so let's look at the packages that we already had in ASP.NET MVC 3 that are still in the box in ASP.NET MVC 4 preview.
If I do a new ASP.NET MVC 3 package, I get the following that are still in ASP.NET MVC 4 preview (the versions below reflect what are in MVC 4 preview):
- jQuery (1.6.2) - Everyone who has been using ASP.NET MVC is familiar with jQuery as it has been included in the box for a while now. It's a great javascript library for DOM manipulation, animation and ajax. Its homepage on the web is here and if you have not yet looked at it, you really should.
- jQuery UI (Combined Library 1.8.11) - jQuery UI is a themeable user interface widget collection that is built on jQuery. There are a lot of widgets in jQuery UI and this NuGet package contains all of them. On the website for jQuery UI you can download a script that only has the widgets in it that you want, which is the best option for using this package because smaller client-side assets mean faster download. This is a good package to start with though, so no need to replace it if you are just messing around.
- jQuery Validation (1.8) - This is a validation plugin built on jQuery. It's nice and easy to use. You can find some documentation on how to use it on the jQuery website, though most people using ASP.NET MVC probably use the unobtrusive validation plugin mentioned below.
- Modernizr (2.0.6) - Modernizr makes it easier for you to do client-side feature-detection. When the script executes on the client, it adds classes to the topmost html element in the page which you can use in your Css to target browsers with specific capabilities. Or, if you need a javascript solution, you can reference Modernizr in your scripts to find out the same information. It's a great little library and I've used it several times.
- Entity Framework (4.1) - Need an object-relational mapper (ORM)? One is included in the box. EF 4.1 is the code-first version, which allows you to avoid the dorky designer approach to configuring your ORM. I've generally found it easy to use.
The following were in MVC 3 (with different versions in some cases) but not as NuGet packages:
- jQuery Unobtrusive Validation (1.0) - This is a helper library that helps you setup and use the jQuery Validation plugin. How does it help, you ask? Well, if you use the data annotation attributes on your view models and use the helpers in ASP.NET MVC to build your forms, you'll get the validations implied by the attributes applied automagically to your fields via data-* attributes. Of course this is just the client-side piece of that.
- jQuery Unobtrusive Ajax (1.0) - Essentially, this library makes it easier to make Ajax calls without writing any/less Javascript. I actually haven't used this one and it looks like most of the first posts on a Google search for "jQuery Unobtrusive Ajax" were written before the release of MVC 3 so they may not be all up to date. So in your quest to mess around with this library, be careful not to look at outdated material.
- ASP.NET Web Pages 2 Core Libraries (2.0.1 Developer Preview) - Bits of ASP.NET MVC (noteably Razor...not sure what else) are built on the Web Pages libraries, which are core for Web Matrix. These are the preview versions of version 2.
- ASP.NET MVC 4 (4.0.1 Developer Preview) - The developer preview of ASP.NET MVC 4...you know, that thing you are trying out. This is the core library of ASP.NET MVC.
Those lists may not be the same as a clean install but reflect what I have on my machine now. Here are the new NuGet packages added for ASP.NET MVC 4 Preview:
- knockoutjs (1.2.9.0) - This is a MVVM-like Javascript framework that basically does databinding and templating. It is surprisingly easy to get started with, especially compared to other MV* javascript frameworks that I have used. Check out the tutorials on the knockoutjs website for more information. This not an official Microsoft project and is not tied to ASP.NET MVC. This has been around a while so many of you will be familiar with it already.
- ASP.NET Universal Providers - Remember the providers that have been in ASP.NET for a while, like Session, Membership, Profile and Role? These are new provider libraries for these things that support a wider range of data stores (apparently include support for Sql Compact Edition and Azure). For a more interesting and complete look at this, you can read more about these providers on Scott Hanselman's blog.
- ASP.NET Optimization - Bundling (0.1) - This one is new and there doesn't appear to be much information on it on the web. However, you can watch this presentation from Build that showed quite extensively how to use it or this post by Tore Lervik on optimizing without drawbacks. If you are watching the Ruby on Rails world, this may look familiar as it sure looks a lot like the Rails 3.1 asset pipeline. But copying in this case is definitely for ASP.NET's benefit.
So that is what is in the box. The one that I am most interested in is the optimization library. I will definitely be messing with that soon.
But I Don't Want That!
If there is a package that you don't want, you can delete it from your solution, packages file and packages directory manually or (a much better option) you can use NuGet to do that. In the image above, you will see that the selected package has a "Manage" button. Click on that. You will get a dialog that looks like this:
Deselect the project or solution that you want it removed for a voila, it removes everything for you. Sweet.