Foreword |
|
xxvii | |
Introduction |
|
xxix | |
|
Chapter 1 Getting Started |
|
|
1 | (30) |
|
A Quick Introduction to ASP.NET MVC |
|
|
1 | (1) |
|
How ASP.NET MVC Fits in with ASP.NET |
|
|
2 | (1) |
|
|
2 | (1) |
|
MVC as Applied to Web Frameworks |
|
|
3 | (1) |
|
|
3 | (3) |
|
|
6 | (4) |
|
|
10 | (1) |
|
|
11 | (1) |
|
|
11 | (1) |
|
New Web Project Experience |
|
|
12 | (1) |
|
|
12 | (1) |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
15 | (1) |
|
Installing MVC 5 and Creating Applications |
|
|
16 | (1) |
|
Software Requirements for ASP.NET MVC 5 |
|
|
16 | (1) |
|
|
16 | (1) |
|
Creating an ASP.NET MVC 5 Application |
|
|
17 | (1) |
|
The New ASP.NET Project Dialog |
|
|
18 | (6) |
|
The MVC Application Structure |
|
|
24 | (3) |
|
ASP.NET MVC and Conventions |
|
|
27 | (1) |
|
Convention over Configuration |
|
|
28 | (1) |
|
Conventions Simplify Communication |
|
|
29 | (1) |
|
|
29 | (2) |
|
|
31 | (18) |
|
|
31 | (3) |
|
A Sample Application: The MVC Music Store |
|
|
34 | (4) |
|
|
38 | (1) |
|
A Simple Example: The Home Controller |
|
|
39 | (3) |
|
Writing Your First Controller |
|
|
42 | (3) |
|
Parameters in Controller Actions |
|
|
45 | (2) |
|
|
47 | (2) |
|
|
49 | (26) |
|
|
50 | (1) |
|
|
50 | (4) |
|
Understanding View Conventions |
|
|
54 | (1) |
|
|
55 | (1) |
|
|
55 | (2) |
|
Understanding ViewBag, ViewData, and ViewDataDictionary |
|
|
57 | (1) |
|
|
58 | (2) |
|
|
60 | (3) |
|
|
63 | (1) |
|
|
63 | (1) |
|
|
64 | (2) |
|
|
66 | (2) |
|
|
68 | (1) |
|
|
68 | (2) |
|
|
70 | (2) |
|
|
72 | (1) |
|
Specifying a Partial View |
|
|
73 | (1) |
|
|
74 | (1) |
|
|
75 | (34) |
|
|
76 | (4) |
|
Scaffolding a Store Manager |
|
|
80 | (1) |
|
|
80 | (2) |
|
Scaffolding and the Entity Framework |
|
|
82 | (3) |
|
Executing the Scaffolding Template |
|
|
85 | (7) |
|
Executing the Scaffolded Code |
|
|
92 | (5) |
|
|
97 | (1) |
|
Building a Resource to Edit an Album |
|
|
97 | (4) |
|
Responding to the Edit POST Request |
|
|
101 | (2) |
|
|
103 | (1) |
|
|
104 | (1) |
|
|
105 | (2) |
|
|
107 | (2) |
|
Chapter 5 Forms and Html Helpers |
|
|
109 | (28) |
|
|
110 | (1) |
|
The Action and the Method |
|
|
110 | (1) |
|
|
111 | (3) |
|
|
114 | (1) |
|
|
115 | (1) |
|
Making Helpers Do Your Bidding |
|
|
115 | (1) |
|
|
116 | (1) |
|
Setting Up the Album Edit Form |
|
|
117 | (1) |
|
|
118 | (6) |
|
Helpers, Models, and View Data |
|
|
124 | (2) |
|
|
126 | (1) |
|
Helpers and Model Metadata |
|
|
127 | (1) |
|
|
127 | (1) |
|
|
128 | (1) |
|
|
129 | (1) |
|
|
129 | (1) |
|
|
129 | (1) |
|
|
129 | (1) |
|
|
130 | (1) |
|
|
130 | (1) |
|
Html.ActionLink and Html.RouteLink |
|
|
131 | (1) |
|
|
132 | (1) |
|
Html.Partial and Html.RenderPartial |
|
|
133 | (1) |
|
Html.Action and Html.RenderAction |
|
|
133 | (2) |
|
|
135 | (2) |
|
Chapter 6 Data Annotations and Validation |
|
|
137 | (22) |
|
Annotating Orders for Validation |
|
|
138 | (3) |
|
Using Validation Annotations |
|
|
141 | (5) |
|
Custom Error Messages and Localization |
|
|
146 | (1) |
|
Looking Behind the Annotation Curtain |
|
|
147 | (1) |
|
Controller Actions and Validation Errors |
|
|
148 | (2) |
|
|
150 | (1) |
|
|
150 | (4) |
|
|
154 | (1) |
|
Display and Edit Annotations |
|
|
155 | (1) |
|
|
155 | (1) |
|
|
156 | (1) |
|
|
156 | (1) |
|
|
157 | (1) |
|
|
157 | (1) |
|
|
158 | (1) |
|
|
158 | (1) |
|
|
158 | (1) |
|
Chapter 7 Membership, Authorization, and Security |
|
|
159 | (54) |
|
Security: Not fun, But Incredibly Important |
|
|
159 | (3) |
|
Using the Authorize Attribute to Require Login |
|
|
162 | (1) |
|
Securing Controller Actions |
|
|
162 | (5) |
|
How AuthorizeAttribute Works with Forms Authentication and the AccountController |
|
|
167 | (2) |
|
|
169 | (3) |
|
Using AuthorizeAttribute to Require Role Membership |
|
|
172 | (2) |
|
|
174 | (1) |
|
Storing additional user profile data |
|
|
174 | (1) |
|
|
174 | (1) |
|
|
175 | (1) |
|
External Login via OAuth and OpenID |
|
|
175 | (1) |
|
Registering External Login Providers |
|
|
176 | (2) |
|
Configuring OpenID Providers |
|
|
178 | (2) |
|
Configuring OAuth Providers |
|
|
180 | (1) |
|
Security Implications of External Logins |
|
|
181 | (1) |
|
Understanding the Security Vectors in a Web Application |
|
|
182 | (1) |
|
Threat: Cross-Site Scripting |
|
|
183 | (10) |
|
Threat: Cross-Site Request Forgery |
|
|
193 | (4) |
|
|
197 | (3) |
|
|
200 | (2) |
|
|
202 | (5) |
|
Proper Error Reporting and the Stack Trace |
|
|
207 | (1) |
|
Using Configuration Transforms |
|
|
208 | (1) |
|
Using Retail Deployment Configuration in Production |
|
|
209 | (1) |
|
Using a Dedicated Error Logging System |
|
|
209 | (1) |
|
Security Recap and Helpful Resources |
|
|
209 | (2) |
|
|
211 | (2) |
|
|
213 | (44) |
|
|
214 | (1) |
|
|
214 | (4) |
|
|
218 | (1) |
|
|
219 | (6) |
|
|
225 | (1) |
|
Adding the Unobtrusive Ajax Script to Your Project |
|
|
225 | (1) |
|
|
226 | (4) |
|
|
230 | (1) |
|
|
230 | (3) |
|
|
233 | (1) |
|
|
233 | (3) |
|
|
236 | (5) |
|
|
241 | (1) |
|
|
242 | (1) |
|
Autocomplete with jQuery UI |
|
|
243 | (3) |
|
JSON and Client-Side Templates |
|
|
246 | (5) |
|
|
251 | (2) |
|
Improving Ajax Performance |
|
|
253 | (1) |
|
Using Content Delivery Networks |
|
|
253 | (1) |
|
|
253 | (1) |
|
Bundling and Minification |
|
|
254 | (1) |
|
|
255 | (2) |
|
|
257 | (42) |
|
Uniform Resource Locators |
|
|
258 | (1) |
|
|
259 | (1) |
|
Comparing Routing to URL Rewriting |
|
|
259 | (1) |
|
|
260 | (1) |
|
Defining Attribute Routes |
|
|
260 | (11) |
|
Defining Traditional Routes |
|
|
271 | (9) |
|
Choosing Attribute Routes or Traditional Routes |
|
|
280 | (1) |
|
|
280 | (2) |
|
|
282 | (2) |
|
|
284 | (1) |
|
Multiple Route Parameters in a Segment |
|
|
285 | (1) |
|
StopRoutingHandler and IgnoreRoute |
|
|
286 | (1) |
|
|
286 | (2) |
|
Inside Routing: How Routes Generate URLs |
|
|
288 | (1) |
|
High-Level View of URL Generation |
|
|
288 | (1) |
|
A Detailed Look at URL Generation |
|
|
289 | (2) |
|
|
291 | (2) |
|
More Examples of URL Generation with the Route Class |
|
|
293 | (1) |
|
Inside Routing: How Routes Tie Your URL to an Action |
|
|
294 | (1) |
|
The High-Level Request Routing Pipeline |
|
|
294 | (1) |
|
|
295 | (1) |
|
|
295 | (1) |
|
Using Routing with Web Forms |
|
|
296 | (1) |
|
|
297 | (2) |
|
|
299 | (34) |
|
|
299 | (2) |
|
Adding a Library as a Package |
|
|
301 | (1) |
|
|
301 | (2) |
|
|
303 | (5) |
|
|
308 | (1) |
|
|
308 | (1) |
|
Using the Package Manager Console |
|
|
309 | (3) |
|
|
312 | (1) |
|
|
313 | (1) |
|
|
313 | (1) |
|
Configuration File and Source Code Transformations |
|
|
314 | (1) |
|
|
315 | (1) |
|
|
316 | (1) |
|
|
317 | (1) |
|
Specifying Files to Include |
|
|
318 | (1) |
|
|
319 | (3) |
|
Framework and Profile Targeting |
|
|
322 | (2) |
|
|
324 | (1) |
|
|
325 | (1) |
|
|
325 | (2) |
|
|
327 | (3) |
|
Using the Package Explorer |
|
|
330 | (2) |
|
|
332 | (1) |
|
Chapter 11 ASP.NET Web API |
|
|
333 | (22) |
|
|
334 | (1) |
|
Getting Started with Web API |
|
|
335 | (1) |
|
Writing an API Controller |
|
|
335 | (1) |
|
Examining the Sample ValuesController |
|
|
335 | (1) |
|
Async by Design: IHttpController |
|
|
336 | (4) |
|
Incoming Action Parameters |
|
|
340 | (1) |
|
Action Return Values, Errors, and Asynchrony |
|
|
340 | (2) |
|
|
342 | (1) |
|
Configuration in Web-Hosted Web API |
|
|
343 | (1) |
|
Configuration in Self-Hosted Web API |
|
|
343 | (3) |
|
Adding Routes to Your Web API |
|
|
346 | (1) |
|
|
347 | (2) |
|
|
349 | (1) |
|
Enabling Dependency Injection |
|
|
350 | (1) |
|
Exploring APIs Programmatically |
|
|
350 | (2) |
|
|
352 | (1) |
|
Web API Example: ProductsController |
|
|
352 | (2) |
|
|
354 | (1) |
|
Chapter 12 Single Page Applications with Angularjs |
|
|
355 | (30) |
|
Understanding and Setting Up AngularJS |
|
|
356 | (1) |
|
|
356 | (1) |
|
|
356 | (1) |
|
|
357 | (2) |
|
Adding AngularJS to the Site |
|
|
359 | (2) |
|
|
361 | (2) |
|
|
363 | (1) |
|
Building Applications and Modules |
|
|
364 | (1) |
|
Creating Controllers, Models, and Views |
|
|
365 | (3) |
|
|
368 | (3) |
|
|
371 | (2) |
|
|
373 | (2) |
|
|
375 | (2) |
|
|
377 | (2) |
|
Editing and Creating Movies |
|
|
379 | (5) |
|
|
384 | (1) |
|
Chapter 13 Dependency Injection |
|
|
385 | (22) |
|
|
385 | (1) |
|
Design Pattern: Inversion of Control |
|
|
386 | (2) |
|
Design Pattern: Service Locator |
|
|
388 | (4) |
|
Design Pattern: Dependency Injection |
|
|
392 | (3) |
|
Dependency Resolution in MVC |
|
|
395 | (2) |
|
Singly Registered Services in MVC |
|
|
397 | (1) |
|
Multiply Registered Services in MVC |
|
|
397 | (2) |
|
|
399 | (3) |
|
Dependency Resolution in Web API |
|
|
402 | (1) |
|
Singly Registered Services in Web API |
|
|
402 | (1) |
|
Multiply Registered Services in Web API |
|
|
403 | (2) |
|
Arbitrary Objects in Web API |
|
|
405 | (1) |
|
Dependency Resolvers in MVC vs. Web API |
|
|
405 | (1) |
|
|
405 | (2) |
|
|
407 | (22) |
|
Understanding Unit Testing and Test-Driven Development |
|
|
408 | (1) |
|
|
408 | (2) |
|
Defining Test-Driven Development |
|
|
410 | (2) |
|
Building a Unit Test Project |
|
|
412 | (1) |
|
Examining the Default Unit Tests |
|
|
413 | (2) |
|
Test Only the Code You Write |
|
|
415 | (1) |
|
Advice for Unit Testing Your ASP.NET MVC and ASP.NET Web API Applications |
|
|
415 | (1) |
|
|
416 | (4) |
|
|
420 | (3) |
|
|
423 | (4) |
|
|
427 | (2) |
|
|
429 | (32) |
|
|
430 | (1) |
|
Turning Request Data into Models |
|
|
430 | (6) |
|
Describing Models with Metadata |
|
|
436 | (2) |
|
|
438 | (4) |
|
|
442 | (1) |
|
|
442 | (2) |
|
|
444 | (1) |
|
|
445 | (1) |
|
|
446 | (1) |
|
|
446 | (1) |
|
|
447 | (10) |
|
|
457 | (1) |
|
|
458 | (3) |
|
Chapter 16 Advanced Topics |
|
|
461 | (60) |
|
|
461 | (1) |
|
|
462 | (8) |
|
|
470 | (3) |
|
|
473 | (1) |
|
Templated Razor Delegates |
|
|
473 | (1) |
|
|
474 | (2) |
|
|
476 | (1) |
|
Configuring a View Engine |
|
|
477 | (1) |
|
|
478 | (1) |
|
|
479 | (1) |
|
|
480 | (2) |
|
New View Engine or New ActionResult? |
|
|
482 | (1) |
|
|
482 | (1) |
|
Introducing ASP.NET Scaffolding |
|
|
482 | (1) |
|
Customizing Scaffold Templates |
|
|
483 | (2) |
|
|
485 | (1) |
|
|
486 | (1) |
|
|
486 | (1) |
|
|
487 | (5) |
|
|
492 | (1) |
|
|
492 | (4) |
|
|
496 | (2) |
|
|
498 | (1) |
|
Defining the Controller: The IController Interface |
|
|
498 | (1) |
|
The ControllerBase Abstract Base Class |
|
|
499 | (1) |
|
The Controller Class and Actions |
|
|
500 | (2) |
|
|
502 | (1) |
|
|
502 | (9) |
|
|
511 | (4) |
|
Using Asynchronous Controller Actions |
|
|
515 | (5) |
|
|
520 | (1) |
|
Chapter 17 Real-World ASP.NET MVC: Building the NUGET.ORG Website |
|
|
521 | (24) |
|
May the Source Be with You |
|
|
522 | (4) |
|
|
526 | (1) |
|
|
527 | (3) |
|
|
530 | (2) |
|
|
532 | (3) |
|
|
535 | (1) |
|
EF Code--Based Migrations |
|
|
536 | (3) |
|
Deployments with Octopus Deploy |
|
|
539 | (1) |
|
Automated Browser Testing with Fluent Automation |
|
|
540 | (1) |
|
Other Useful NuGet Packages |
|
|
541 | (1) |
|
|
541 | (1) |
|
|
542 | (1) |
|
AnglicanGeek.MarkdownMailer |
|
|
543 | (1) |
|
|
543 | (1) |
|
|
544 | (1) |
|
APPENDIX: ASP.NET MVC 5.1 |
|
|
545 | (20) |
|
ASP.NET MVC 5.1 Release Description |
|
|
545 | (4) |
|
|
546 | (1) |
|
Upgrading MVC 5 Projects from MVC 5.1 |
|
|
546 | (1) |
|
Upgrading an MVC 5 Application to 5.1 |
|
|
547 | (2) |
|
Enum Support in ASP.NET MVC Views |
|
|
549 | (4) |
|
Attribute Routing with Custom Constraints |
|
|
553 | (5) |
|
Route Constraints in Attribute Routing |
|
|
554 | (1) |
|
ASP.NET MVC 5.1 Example: Adding a Custom LocaleRoute |
|
|
554 | (4) |
|
Bootstrap and JavaScript Enhancements |
|
|
558 | (5) |
|
Editor For Now Supports Passing HTML Attributes |
|
|
558 | (3) |
|
Client-Side Validation for MinLength and MaxLength |
|
|
561 | (1) |
|
Three Small but Useful Fixes to MVC Ajax Support |
|
|
562 | (1) |
|
|
563 | (2) |
Index |
|
565 | |