About this Book

The ASP.NET MVC Framework was the vision of Scott Guthrie in early 2007. With a prototype demonstration in late 2007 and a key hire of Phil Haack as the Senior Program Manager of the feature team, Mr. Guthrie made the vision a reality. At a time when the .NET community was becoming frustrated that other platforms had great MVC frameworks such as Tapestry, Rails, and the like, Web Forms was losing favor as developers struggled to make it do things unimagined when it became public in 2001. Castle MonoRail was a very capable framework and continues to have strong leadership behind it, but the broader .NET industry needed a change from Web Forms. Phil Haack, with his experience outside of Microsoft and in the open source community, came in and led the ASP.NET MVC Framework team to a successful 1.0 release that the .NET community is excited about.

ASP.NET MVC has had the benefit of learning from other popular MVC frameworks, such as Struts, WebWork, Tapestry, Rails, MonoRail, and others. It also came about as C# started to push away its fully statically typed roots. The language enhancements introduced with .NET 3.5 have been fully leveraged in the ASP.NET MVC Framework, giving it a huge advantage over frameworks that came before as well as all the Java frameworks that are tied to the currently supported Java syntax.

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 is a fundamental shift in thinking because they grew up with Web Forms being “normal” web development.

This book starts at a point that is past the documentation and online tutorials available on the ASP.NET MVC website (at http://www.asp.net/mvc/). If you’re just getting started with ASP.NET, you will want to read some of the older books covering the ASP.NET pipeline and server runtime. Because ASP.NET MVC layers on ASP.NET, it is important to understand the fundamentals. If you are a current ASP.NET developer, you will find that this book does not insult your intelligence. It is a fast-paced book aimed at giving you the why and not just the how.

Because ASP.NET MVC 2 is a new technology, you can expect several books to cover the topic. This is a framework, however, that is not sitting still. Since its first release in March 2009, several books have been released, but the community is always finding new and better ways to use the framework. The newest ideas make their way to the MvcContrib project, which is able to release frequently as new additions are contributed. Because of this dynamic, this book covers ASP.NET MVC with MvcContrib sprinkled throughout. The authors are all actively developing with the framework, and MvcContrib plays a vital part in every application.

This books 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. With this, we hope that 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.

Necessary tools

This book was written for developers using Visual Studio 2008 SP1 or Visual Studio 2010. The majority of the industry will continue developing with Visual Studio 2008 for several years to come, so we have produced code samples and screenshots with this version with ASP.NET MVC 2 installed. All samples work equally well in either the 2008 or 2010 version of Visual Studio.

We have intentionally focused on the usage of ASP.NET MVC 2 that is common to both .NET 3.5 SP1 and .NET 4. With the .NET 4 framework, ASP.NET has introduced an autoencoding code nugget syntax, <%: someVariable %>. We continue to use <%= someVariable %> so that the code works with both versions of the .NET framework. If you are using Visual Studio 2010, feel free to use the new autoencoding code nugget.

You are also free to use Visual Web Developer Express to develop your ASP.NET MVC web applications. You will find some differences in the examples when using this tool, but the same techniques and code apply.

Who should read this book?

This book is mostly written for senior, mid-level, and junior developers working with ASP.NET. Parts 3 and 4 of the book will benefit application architects and team leaders who have to choose techniques to employ on their teams. The authors are very experienced developers as well as strong leaders in their companies, local community, and the industry. All five authors are recognized by Microsoft with the Microsoft Most Valuable Professional (MVP) award. Whereas the first edition was aimed toward senior-level professionals only, this version strives to be a fast-paced walkthrough ranging from introductory material to advanced concepts. Whether you are familiar with other MVC frameworks or not, this book will push your knowledge further than you may be accustomed to when reading a technology book.

Because you’ll use many libraries for specific things in any real project, we didn’t shy away from using these as well. We feel that avoiding other libraries for the sake of simplicity makes it very difficult for readers to apply the knowledge gained while reading. With that in mind, we use popular libraries that we are used to, such as MvcContrib, NAnt, NUnit, StructureMap, Windsor, Castle, Rhino Mocks, Log4Net, NHibernate, Tarantino, AutoMapper, Iesi.Collections, and many others.

Also, we have taken care to separate concerns when necessary. We always separate data access from the domain model and the presentation layer, and we separate presentation model from views; therefore, you will not see simplistic examples such as performing a query directly from a UI controller. This is bad practice in anything but the most trivial applications, such as that serving http://PartyWithPalermo.com (a three-page site). Real applications have many screens, and embedding data access and other logic in the UI is a recipe for a codebase that is very costly to maintain.

We’ve done our best to call out where we expect existing ASP.NET knowledge to tie the example together, but if you find yourself wondering what an http module is, you’ll probably want to read a book that covers the foundations of ASP.NET, such as ASP.NET 4.0 in Practice, also from Manning.

Roadmap

This book is organized so that the reader who wishes to read from cover to cover will experience a nice flow of topics that incrementally build on each other. Generally, from front to back, the topics become progressively more in-depth and require a greater degree of understanding. If you have already developed an application with the first version of ASP.NET MVC, or if you have already read the first edition of this book, you can jump around at will without the risk of getting lost. If you have never developed with ASP.NET MVC before, you would do well to read the book from beginning to end.

The text is split into four parts covering beginner, journeyman, master, and cross-cutting advanced topics. Each of these parts begins with an introduction that gives some indication about what to expect from the chapters in that particular part. If you need to learn the fundamentals first, start with part 1. If you feel comfortable with your knowledge, feel free to start with part 2 and then come back to part 1 if there are any topics on which you need a refresher. Part 3 will stretch your skills even if you have programmed with ASP.NET MVC before. Finally, part 4 will push your ASP.NET MVC development further with some real-world needs.

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.NETMVC2inAction.

Author Online

The purchase of ASP.NET MVC 2 in Action includes 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.NETMVC2inAction.

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.29.22