Introduction --- Professional ASP.NET MVC 1.0

Overview

Why does the world need Yet Another Web Framework?

This is the question that is most likely on your mind — or perhaps it's what you were thinking when you saw this book sitting on the shelf. We each asked ourselves this many times over the last few years.

Indeed there are many frameworks out there today flavored with every buzzword the industry can think of. In short, it's easy to be skeptical. Yet as we, the authors, delve deeper into the latest and greatest web framework, we're each starting to realize just how far the industry has come in the last 10 years.

Rob began programming for the Web with Classic ASP in 1997 and was giddy with excitement. When .NET came out, he remembers running around his office, stopping everyone from working and explaining that the world just tilted on its axis.

We all feel the same way about ASP.NET MVC. Not because it's "something different" but because it offers developers the ultimate chance to "do it their way." You don't like the way the platform renders the View? Change it! Just about every part of the ASP.NET MVC Framework is "swappable" — if the shoes pinch, get different shoes. Don't like ties? Why not a bow tie? You're totally in control.

ASP.NET MVC is a web framework that comes with a bunch of conventions to make your life easier when you follow them, but if you don't want them, the framework is quick to step out of your way so that you can get your work done in the way you like.

This book is going to go into the "out-of-the-box" experience you'll have with ASP.NET MVC, but more importantly you'll learn practical ways that you can extend ASP.NET MVC with your own magic — then hopefully share that magic with others.

Because of this extensibility and attention to "doing it your way," we're happy to embrace Yet Another Web Framework and hope you are willing to come along with us for the ride.

Who This Book is For

This book is for web developers who are looking to add more complete testing to their web sites, and who are perhaps ready for "something different."

In some places, we assume that you're somewhat familiar with ASP.NET Web Forms, at least peripherally. There are a lot of ASP.NET Web Forms developers out there who are interested in ASP.NET MVC, so there are a number of places in this book where we contrast the two technologies. Even if you're not already an ASP.NET developer, you might still find these sections interesting for context, as well as for your own edification, as ASP.NET MVC may not be the web technology that you're looking for.

It's worth noting, yet again, that ASP.NET MVC is not a replacement for ASP.NET Web Forms. Many web developers have been giving a lot of attention to other web frameworks out there (Ruby on Rails, Django), which have embraced the MVC (Model-View-Controller) application pattern, and if you're one of those developers, or even if you're just curious, this book is for you.

MVC allows for (buzzword alert!) a "greater separation of concerns" between components in your application. We'll go into the ramifications of this later on, but if it had to be said it in a quick sentence: ASP.NET MVC is ASP.NET Unplugged. ASP.NET MVC is a tinkerer's framework that gives you very fine-grained control over your HTML and JavaScript, as well as complete control over the programmatic flow of your application.

There are no declarative server controls in MVC, which some people may like, others may dislike. In the future, the MVC team may add declarative view controls to the mix, but these will be far different from the components that ASP.NET Web Forms developers are used to, in which a control encapsulates both the logic to render the view and the logic for responding to user input etc. Having all that encapsulated in a single control in the view would violate the "separation of concerns" so central to this framework. The levels of abstraction have been collapsed, with all the doors and windows opened to let the air flow freely.

The final analogy we can throw at you is that ASP.NET MVC is more of a motorcycle, whereas ASP.NET Web Forms might be more like a minivan, complete with airbags and a DVD player in case you have kids and you don't want them to fight while you're driving to the in-laws for Friday dinner. Some people like motorcycles, some people like minivans. They'll both get you where you need to go, but one isn't technically better than the other.

How This Book is Structured
This book is divided into three very broad sections, each comprising several chapters.

The first third of the book is concerned with introducing the MVC pattern and how ASP.NET MVC implements that pattern.

Chapter 1 starts off with a description of the Model-View-Controller pattern, explaining the basic concepts of the pattern and providing a bit of its history. The chapter goes on to describe the state of the MVC pattern on the Web today as it is implemented by various frameworks, such as ASP.NET MVC.

Chapter 2 covers the ways that ASP.NET MVC is different from ASP.NET Web Forms and how to get ASP.NET MVC up and running.

Chapter 3 explores the structure of a standard MVC application and covers what you get out of the box. It covers some of the conventions and the digs a little under the hood to take a look at the entire request lifecycle for an ASP.NET MVC request.

Chapter 4 digs deep into routing to describe the role that URLs play in your application and how routing figures into that. It also differentiates routing from URL rewriting and covers a bit on extending routing and writing unit tests for routes.

Chapter 5 takes a look at controllers and controller actions — what they are and how to write them. It also covers action results, which are returned by controller actions and what they are used for.

Chapters 6–7 cover views and view engines, and then add a little flavor on top by examining the role that AJAX plays in your views.

The second third of the book focuses entirely on advanced techniques and extending the framework.

Chapter 8 goes into detail on action filters, which provide an extensibility point for adding cross-cutting behaviors to action methods.

Chapter 9 covers security and good practices for building a secure application.

Chapter 10 covers various approaches to building and interacting with different types of services made available over the Web.

Chapter 11 provides a brief introduction to Test Driven Development (TDD) as it applies to ASP.NET MVC. It then goes on to examine real-world patterns and practices for building applications that are testable.

The final part of the book covers guidance and best practices as well as providing a look ahead at the future of the ASP.NET MVC platform.

Chapter 12 goes into detail on how Web Forms and MVC fit together and covers ways to have the two coexist in the same application, as well as how to migrate an app from Web Forms to MVC.

We tried to organize the book in such a way that when you read it in order, each chapter builds on the previous one. If you already familiar with ASP.NET MVC you might skip directly to Chapter 4 and go from there.

What You Need to Use This Book
To use ASP.NET MVC, you'll probably want a copy of Visual Studio. You can use Visual Studio 2008 Web Developer Express SP1 or any of the paid versions of Visual Studio 2008 (such as Visual Studio 2008 Professional). If you're going to use the Web Developer Express edition of Visual Studio, you need to confirm that you're using SP1. ASP.NET MVC requires that you use Web Application Projects (WAPs) rather than Web Site Projects, and this functionality was added in SP1 of Web Developer Express.

You will also need to make sure that you have the .NET Framework 3.5 installed at minimum. The runtime does not require .NET 3.5 SP1 to run.

The following list shows you where to go to download the required software.

Conventions
To help you get the most from the text and keep track of what's happening, we've used a number of conventions throughout the book.

Occasionally the product team will take a moment to provide an interesting aside, for bits of trivia, and those will appear in boxes like this:

 Important  Product Team Aside: Boxes like this one hold tips, tricks, trivia from the ASP.NET Product Team or some other information that is directly relevant to the surrounding text.
 
 Note  Tips, hints and tricks to the current discussion are offset and placed in italics like this.
 

As for styles in the text:

  • We highlight new terms and important words when we introduce them.
  • We show keyboard strokes like this: Ctrl+A.
  • We show file names, URLs, and code within the text like so: persistence.properties.
  • We present code in two different ways:


In code examples, we highlight important code that we want to emphasize with a gray background.

The gray highlighting is not used for code that's less important in the present context, or has been shown before.

Source Code
The main nerddinner.com code download is hosted at codeplex and the most up-to-date code will always be available at http://www.codeplex.com/nerddinner. The original nerddinner.com code that matches the code used in the book is hosted at wrox.com from the book page.

As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All of the source code used in this book is available for downloading at www.wrox.com. Once at the site, simply locate the book's title (either by using the Search box or by using one of the title lists) and click the Download Code link on the book's detail page to obtain all the source code for the book.

 Note  Because many books have similar titles, you may find it easiest to search by ISBN; this book's ISBN is 978-0-470-38461-9.
 

Once you download the code, just decompress it with your favorite compression tool. Alternately, you can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.

 

Errata
We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save another reader hours of frustration, and at the same time you will be helping us provide even higher-quality information.

To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page, you can view all errata that has been submitted for this book and posted by Wrox editors. A complete book list including links to each book's errata is also available at www.wrox.com/misc-pages/booklist.shtml.

If you don't spot "your" error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We'll check the information and, if appropriate, post a message to the book's errata page, and fix the problem in subsequent editions of the book.

p2p.wrox.com
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.

At http://p2p.wrox.com you will find a number of different forums that will help you not only as you read this book but also as you develop your own applications. To join the forums, just follow these steps:

Go to p2p.wrox.com, and click the Register link.

Read the terms of use, and click Agree.

Complete the required information to join as well as any optional information you wish to provide, and click Submit.

You will receive an e-mail with information describing how to verify your account and complete the joining process.

 Note  You can read messages in the forums without joining P2P, but in order to post your own messages, you must join.
 

Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

posted on 2010-06-23 15:35 Yan-Feng 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/yan-feng/archive/2010/06/23/1763649.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值