مشخصات کتاب
-
Jonathan McCracken
-
2014
-
انگلیسی
-
23156
-
662
-
0
Test-Drive ASP.NET MVC
دوره آموزش MVC
Acknowledgments 8
Preface 10
What Makes ASP.NET MVC Special? . . . . . . . . . . . . . . . 10
Why Test-Driven Development? . . . . . . . . . . . . . . . . . . 12
Who Should Read This Book? . . . . . . . . . . . . . . . . . . . 13
What’s in This Book? . . . . . . . . . . . . . . . . . . . . . . . . 13
What’s New in ASP.NET MVC 2.0? . . . . . . . . . . . . . . . . 14
Online Resources . . . . . . . . . . . . . . . . . . . . . . . . . . 16
I Fundamentals 17
1 Getting Started with ASP.NET MVC 18
1.1 How ASP.NET MVC Works . . . . . . . . . . . . . . . . . 18
1.2 Installing MVC . . . . . . . . . . . . . . . . . . . . . . . . 21
1.3 MVC in Five Minutes: Building Quote-O-Matic . . . . . 24
2 Test-Driven Development 31
2.1 TDD Explained . . . . . . . . . . . . . . . . . . . . . . . 31
2.2 Test-Driving “Hello World” . . . . . . . . . . . . . . . . . 36
II Building an Application 42
3 Getting Organized with MVC 43
3.1 Time Management with GetOrganized . . . . . . . . . . 43
3.2 Reading Data . . . . . . . . . . . . . . . . . . . . . . . . 45
3.3 Creating a To-Do . . . . . . . . . . . . . . . . . . . . . . 56
3.4 Deleting: Creating an Action Without a View . . . . . . 62
3.5 Updating: Marking a To-Do as Complete . . . . . . . . 66
4 Working with Controllers 71
4.1 Creating Topics . . . . . . . . . . . . . . . . . . . . . . . 72
4.2 Using the FormCollection and TempData Objects . . . 77
4.3 Adding a Little Color with jQuery . . . . . . . . . . . . . 80
4.4 Controllers Talking to Controllers . . . . . . . . . . . . 87
5 Managing State and Files with Controllers 93
5.1 Enabling Filters and Results with Controllers . . . . . 93
5.2 Logging In . . . . . . . . . . . . . . . . . . . . . . . . . . 100
5.3 Testing Routes in MVC . . . . . . . . . . . . . . . . . . . 109
5.4 Storing Information in Memory . . . . . . . . . . . . . . 109
5.5 Manipulating Files . . . . . . . . . . . . . . . . . . . . . 119
6 Enhancing Views with HTML Helpers and Master Pages 127
6.1 Making Our Site Presentable with HTML Helpers . . . 128
6.2 Building a Custom HTML Helper . . . . . . . . . . . . . 135
6.3 Simplifying Page Layouts with Master Pages . . . . . . 139
6.4 Adding Validations Using ModelStateDictionary . . . . 143
6.5 Replacing Web Controls with Advanced HTML Helpers 146
7 Composing Views with Ajax and Partials 151
7.1 Working with Ajax . . . . . . . . . . . . . . . . . . . . . . 152
7.2 Finding It in a Snap with Autocomplete . . . . . . . . . 157
7.3 Using Partials to Reduce Duplication . . . . . . . . . . 161
III Integrating with Other Frameworks 171
8 Persisting Your Models 172
8.1 MVC’s Next Top Model: NHibernate . . . . . . . . . . . 173
8.2 Using the Repository Pattern . . . . . . . . . . . . . . . 174
8.3 Mapping with Fluent NHibernate . . . . . . . . . . . . . 177
8.4 Creating and Reading Records . . . . . . . . . . . . . . 179
8.5 Editing Models . . . . . . . . . . . . . . . . . . . . . . . . 183
8.6 Deleting Records . . . . . . . . . . . . . . . . . . . . . . 185
8.7 Additional ORM Data Relationships . . . . . . . . . . . 186
9 Integrating Repositories with Controllers 188
9.1 Fixing the NHibernate Session Inside MVC . . . . . . . 189
9.2 Using Inversion of Control with the IControllerFactory 192
9.3 Injecting Repositories into Controllers . . . . . . . . . . 197
9.4 Creating a Custom Action Filter . . . . . . . . . . . . . 200
9.5 Linking NHibernate and MVC Validations . . . . . . . . 203
9.6 Preventing Performance Problems with Profiling . . . . 206
10 Building RESTful Web Services 210
10.1 Use SOAP or Take a REST Instead? . . . . . . . . . . . 210
10.2 Creating a Web Service . . . . . . . . . . . . . . . . . . . 213
10.3 Publishing to Blogger . . . . . . . . . . . . . . . . . . . . 220
IV Security and Deployment 228
11 Security, Error Handling, and Logging 229
11.1 Applying Additional Security . . . . . . . . . . . . . . . 230
11.2 Using an Action Filter to Handle Errors . . . . . . . . . 238
11.3 Using Logging to See What Went Wrong . . . . . . . . . 241
11.4 Checking for a Pulse with ASP.NET Health Monitoring 245
12 Build and Deployment 247
12.1 Automating Builds . . . . . . . . . . . . . . . . . . . . . 247
12.2 Using MSBuild to Automate the Build . . . . . . . . . . 249
12.3 Deploying to Production . . . . . . . . . . . . . . . . . . 259
A Bibliography 268
Index 270