Chapter 23. Upgrading to ASP.NET MVC 4

 

This chapter covers

  • Switching views based on device
  • Exploring bundling capabilities
  • Removing unnecessary Razor code

When upgrading an application to ASP.NET MVC 4, you can take advantage of new framework features like bundling, Razor enhancements, and DisplayModes. This is exactly what we’ll be doing in this chapter: looking at what upgrading to MVC 4 will do for you with regards to adding functionality to your system, deleting code, and easing ongoing maintenance.

Bundling is slick out-of-the-box support for combining and minifying both JavaScript and Cascading Style Sheet (CSS) files, which results in faster page loads. We’ll look at some small but exciting changes to the Razor view engine that allow developers the chance to clean up the tedious and boilerplate code that can clutter MVC views. These changes do not add functionality to the applications you build using Razor; instead they’re syntactic sugar that eliminate much of the verbosity of writing view code. But first, we’ll investigate DisplayModes, a powerful feature that can be used to support different views for mobile devices.

23.1. Runtime view selection with DisplayModes

23.2. Combining and minifying client assets

23.3. Improvements to Razor

23.4. Summary