ASP.NET MVC Framework Unleashed (Unleashed) (1ST)

  • ポイントキャンペーン

ASP.NET MVC Framework Unleashed (Unleashed) (1ST)

  • Sams(2009/07発売)
  • ただいまウェブストアではご注文を受け付けておりません。 ⇒古書を探す
  • 製本 Paperback:紙装版/ペーパーバック版/ページ数 723 p.
  • 言語 ENG
  • 商品コード 9780672329982
  • DDC分類 006.7882

Full Description


In this book, world-renowned ASP.NET expert and member of the Microsoft ASP.NET team Stephen Walther shows experienced developers how to use Microsoft's new ASP.NET MVC Framework to build web applications that are more powerful, flexible, testable, manageable, scalable, and extensible. Writing for professional programmers, Walther explains the crucial concepts that make the Model-View-Controller (MVC) development paradigm work so well and shows exactly how to apply them with the ASP.NET MVC Framework. From controllers and actions to views and models, Walther demonstrates how to apply each ASP.NET MVC Framework feature in real-world projects. In Part II, you'll walk step-by-step through building a full-fledged ASP.NET MVC blog application that implements capabilities ranging from data access to validation. Through this case study, you'll learn how to build ASP.NET MVC applications using test-driven development processes that enable rapid feedback, greater productivity, and better quality. Throughout, Walther presents extensive code examples, reflecting his unsurpassed experience as an ASP.NET instructor, a leading commercial developer, and now as a member of Microsoft's ASP.NET development team. Understand how to:Build enterprise-scale web applications far more rapidly and effectively Develop web applications that are easier to maintain and extend over time Gain unprecedented control over the appearance of your website or application Expose intuitive URLs that are friendlier to search engines and users alike Create ASP.NET MVC models that contain all your application's business, validation, and data access logic Make the most of HTML helpers, model binders, action filters, routing, and authentication Efficiently deploy your ASP.NET MVC applications Use the lightweight JQuery JavaScript library to easily find and manipulate HTML elements Create ASP.NET MVC applications using unit test and mock object framework

Contents

Introduction 1How This Book Is Organized 1What You Should Know Before Reading This Book 2What Software Do You Need? 2Where Do You Download the Code Samples? 3If You Like This Book 3Part I Building ASP.NET MVC ApplicationsChapter 1 An Introduction to ASP.NET MVC 7A Story with a Moral 7What Is Good Software? 8Avoiding Code Smells 9Software Design Principles 10Software Design Patterns 11Writing Unit Tests for Your Code 12Test-Driven Development 13Short-Term Pain, Long-Term Gain 14What Is ASP.NET MVC? 14ASP.NET MVC Is Part of the ASP.NET Framework 14The Origins of MVC 15The Architecture of an ASP.NET MVC Application 16Understanding the Sample ASP.NET MVC Application 17ASP.NET MVC Folder Conventions 19Running the Sample ASP.NET MVC Application 19Chapter 2 Building a Simple ASP.NET MVC Application 23Starting with a Blank Slate 23Creating the Database 25Creating the Model 27Creating the Controller 30Creating the Views 37Adding the Index View 38Adding the Create View 42Chapter 3 Understanding Controllers and Actions 47Creating a Controller 47Returning Action Results 51Returning a View Result 52Returning a Redirect Result 55Returning a Content Result 57Returning a JSON Result 59Returning a File Result 63Controlling How Actions Are Invoked 65Using AcceptVerbs 65Using ActionName 70Using ActionMethodSelector 72Handling Unknown Actions 76Testing Controllers and Actions 78Chapter 4 Understanding Views 83Creating a View 83Using View Data 87Typed and Untyped Views 88Creating Strongly Typed Views 94Preventing JavaScript Injection Attacks 95Using Alternative View Engines 97Creating a Custom View Engine 99Testing Views 105Test the View Result 105Test HTML Helpers 108Test a Custom View Engine 114Chapter 5 Understanding Models 119Creating a Data Model 120Creating a Data Model with the Microsoft Entity Framework 120Listing Records 124Getting a Single Record 126Creating Records 127Editing Records 128Deleting Records 131Using the Repository Pattern 132Creating a Product Repository 133Using the Dependency Injection Pattern 138Creating a Generic Repository 139Using the Generic Repository with the Entity Framework 141Using the Generic Repository with LINQ to SQL 144Extending the Generic Repository 147Testing Data Access 149Testing with a Mock Repository 150Testing with a Fake Generic Repository 155Chapter 6 Understanding HTML Helpers 159Using the Standard HTML Helpers 160Rendering Links 160Rendering Image Links 161Rendering Form Elements 162Rendering a Form 166Rendering a Drop-Down List 167Encoding HTML Content 169Using Antiforgery Tokens 169Creating Custom HTML Helpers 173Using the TagBuilder Class 176Using the HtmlTextWriter Class 180Creating a DataGrid Helper 183Adding Sorting to the DataGrid Helper 190Adding Paging to the DataGrid Helper 192Testing Helpers 201Chapter 7 Understanding Model Binders and Action Filters 207Understanding Model Binders 207Using the Default Model Binder 210Binding to Complex Classes 212Using the Bind Attribute 218Using Bind with Classes 221Using Prefixes When Binding 225Using the Form Collection Model Binder 228Using the HTTP Posted File Base Model Binder 231Creating a Custom Model Binder 233Understanding Action Filters 236Creating a Log Action Filter 237Chapter 8 Validating Form Data 241Understanding Model State 241Understanding the Validation Helpers 245Styling Validation Error Messages 247Prebinding and Postbinding Validation 248Validating with a Service Layer 251Validating with the IDataErrorInfo Interface 258Testing Validation 264Chapter 9 Understanding Routing 269Using the Default Route 269Debugging Routes 274Creating Custom Routes 275Creating Route Constraints 277Using Regular Expression Constraints 278Using the HttpMethod Constraint 280Creating an Authenticated Constraint 280Creating a NotEqual Constraint 283Using Catch-All Routes 285Testing Routes 288Using the MvcFakes and RouteDebugger Assemblies 289Testing If a URL Matches a Route 289Testing Routes with Constraints 292Chapter 10 Understanding View Master Pages and View User Controls 295Understanding View Master Pages 295Creating a View Master Page 295Creating a View Content Page 300Setting the Master Page from the Controller 302Setting the Master Page Title 303Nested Master Pages 306Passing View Data to Master Pages 308Understanding View User Controls 311Passing View Data to User Controls 314Using a View User Control as a Template 319Chapter 11 Better Performance with Caching 325Using the OutputCache Attribute 325Don't Cache Private Data 330What Gets Cached? 331Setting the Cache Location 333Varying the Output Cache by Parameter 335Varying the Output Cache 337Removing Items from the Output Cache 341Using Cache Profiles 343Using the Cache API 344Using the HttpCachePolicy Class 345Using the Cache Class 347Testing the Cache 353Testing the OutputCache Attribute 353Testing Adding Data to the Cache 355Chapter 12 Authenticating Users 365Creating Users and Roles 365Using the Web Site Administration Tool 365Using the Account Controller 367Authorizing Users 368Using the Authorize Attribute 368Using the User Property 372Configuring Membership 374Configuring the Membership Database 375Configuring Membership Settings 378Using the Membership and Role Manager API 381Using Windows Authentication 385Configuring Windows Authentication 385Authenticating Windows Users and Groups 386Testing Authorization 390Testing for the Authorize Attribute 390Testing with the User Model Binder 393Chapter 13 Deploying ASP.NET MVC Applications 401Configuring IIS for ASP.NET MVC 401Integrated Versus Classic Mode 402Using ASP.NET MVC with Older Versions of IIS 403Adding Extensions to the Route Table 403Hosted Server 408Creating a Wildcard Script Map 410Mixing ASP.NET Web Forms and ASP.NET MVC 414Modifying the Visual Studio Project File 415Adding the Required Assemblies 415Modifying the Web Configuration File 416Modify the Global.asax File 422Using Web Forms and MVC 424Bin Deploying an ASP.NET MVC Application 424Chapter 14 Working with Ajax 427Using the Ajax Helpers 427Debugging Ajax 428Posting a Form Asynchronously 430Displaying Progress 435Updating Content After Posting 443Performing Validation 447Providing Downlevel Browser Support 452Retrieving Content Asynchronously 454Highlighting the Selected Link 459Creating a Delete Link 462Providing Downlevel Browser Support 468Using the AcceptAjax Attribute 473Chapter 15 Using jQuery 479Overview of jQuery 479Including the jQuery Library 480jQuery and Visual Studio Intellisense 481Using jQuery Selectors 482Adding Event Handlers 487Using jQuery Animations 489jQuery and Ajax 491Using jQuery Plug-Ins 498Part II Walkthrough: Building the Unleashed Blog ApplicationChapter 16 Overview of the Application 505What Is Test-Driven Development? 505Why Do Test-Driven Development? 506The KISS and YAGNI Principles 507Waterfall Versus Evolutionary Design 507TDD Tests Are Not Unit Tests 508Tests Flow from User Stories 508Unit Testing Frameworks 509Bibliography of Test-Driven Development 509Chapter 17 Database Access 511Creating the Unleashed Blog Project 511Creating Our First Test 514Creating New Blog Entries 520Refactoring to Use the Repository Pattern 524Creating a Fake Blog Repository 526Creating an Entity Framework Repository 530Creating the Database Objects 531Creating the Entity Framework Data Model 532Creating the Entity Framework Blog Repository 534Using the Entity Framework Repository 537Chapter 18 Creating the Routes 543Creating the Controller Tests 543Creating the Route Tests 553Creating the Archive Routes 561Trying Out the Archive Controller 564Chapter 19 Adding Validation 567Performing Validation in the Simplest Possible Way 567Refactoring the Test Code 573Validating the Length of a Property 576A Web Browser Sanity Check 578Refactoring to Use a Service Layer 581Adding Business Rules 586Chapter 20 Paging, Views, and Ajax 593Adding Paging Support 593Adding the Views 605Adding Ajax Support 612Chapter 21 Adding Comments 621Implementing Comments 621Adding Comments to the Database 633Displaying Comments and Comment Counts 637Part III AppendixesAppendix A C# and VB.NET Language Features 647Type Inference 647Object Initializers 648Anonymous Types 649Nullable Types 651Extension Methods 652Generics 654Lambda Expressions 655LINQ 656Appendix B Using a Unit Testing Framework 659Using Visual Studio Unit Test 660Understanding the Test Attributes 666Using Assertions 669Running the Tests 669Limiting Visual Studio Test Results 671Using NUnit 672Creating an NUnit Unit Test Project 672Creating a Test 674Running Tests 676Appendix C Using a Mock Object Framework 679Understanding the Terminology 680Installing Moq 680Using Moq to Create a Class from an Interface 681Returning Fake Values 690