about this book

The ASP.NET MVC framework has come a long way over the last few years.

It was originally the vision of Scott Guthrie in early 2007, and with a subsequent prototype demonstration in late 2007 and the hire of Phil Haack as a Senior Program Manager, this vision became a reality. Several public previews of the framework were released over the following year, followed by the final release of ASP.NET MVC 1.0 in early 2009.

At a time when many web developers in the .NET community were becoming frustrated that other platforms had great MVC frameworks available (such as Ruby on Rails) that provided lightweight, clean, and simple ways of building web applications, ASP.NET Web Forms was losing favor. Developers struggled to make it do things for which it was never initially intended, and for many developers with a web background, the complexities of the page lifecycle and the pseudo-stateful model were very alien concepts.

ASP.NET MVC aimed to solve this problem by positioning itself as an alternative platform to Web Forms for developing web applications on the .NET platform. Taking inspiration from other frameworks such as Rails, MonoRail, and others, ASP.NET MVC provided a much cleaner way for .NET developers to build web applications.

With the second major release in March 2010, ASP.NET MVC 2 added support for several important features that were missing from the first release (such as validation, areas, and templated helpers). Now with ASP.NET MVC 4, Microsoft has built on an already solid platform and has introduced several major new changes—the new Razor view engine replaces the Web Forms ASPX engine as the default mechanism for rendering HTML, and the framework embraces many of the new features introduced with .NET 4.

For people who have a diversified software background, ASP.NET MVC is a great, familiar addition to the Visual Studio development experience. For those who began their software career with .NET 1.0 or later, it’s a fundamental shift in thinking because they grew up with Web Forms being “normal” web development.

This book starts by providing an introduction to ASP.NET MVC, which should be helpful if you’ve never used ASP.NET MVC before, or if you have experience with a previous version and are interested in seeing what’s new in version 3. Following this, we’ll dive deeper into the core concepts that are so important to modern .NET web development, including the use of Ajax, clean URLs, dependency injection, and validation.

This book aims to have a long-lasting place on your bookshelf. The API will evolve, but the principles behind using an MVC framework and the ways to structure URLs, tests, and application layers are more durable. We hope this book serves not only as a rigorous foray into ASP.NET MVC development but also as a good guide toward developing long-lived web applications on the .NET platform.


The book is divided into 3 main parts:

Who should read this book?

This book is mostly written for senior, mid-level, and junior developers working with ASP.NET. The first section of the book will mostly benefit developers who have never worked with ASP.NET MVC before, or who have experience with older versions and are looking to upgrade.

Parts 2 and 3 of the book will benefit developers of all experience levels looking to expand their knowledge of ASP.NET MVC in order to use it within real world applications. Additionally, these chapters will also be of benefit to application architects and team leaders who have to choose techniques to employ on their teams.

This book assumes that you are already familiar with web-development concepts (such as HTTP, HTML, CSS, and JavaScript) and that you have experience with the C# language.

Source code conventions and downloads

All source code in listings or in text is in a fixed-width font like this to separate it from ordinary text. Code annotations accompany many of the listings, highlighting important concepts. In some cases, numbered bullets link to explanations that follow the listing.

The source code for the examples in this book is available online from the publisher’s website at http://www.manning.com/ASP.NETMVC4inAction.

Author Online

Readers of ASP.NET MVC 4 in Action have free access to a private web forum run by Manning Publications, where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum and subscribe to it, point your web browser to http://www.manning.com/ASP.NETMVC4inAction.

This page provides information about how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct on the forum. Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the authors can take place. It’s not a commitment to any specific amount of participation on the part of the authors, whose contribution to the book’s forum remains voluntary (and unpaid). We suggest you try asking them some challenging questions, lest their interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.