Read more
Provides information on using the ASP.NET MVC 5 framework, covering such topics as the controllers, models, forms, Ajax, routing, NuGet, and unit testing.
List of contents
FOREWORD xxvii
INTRODUCTION xxix
CHAPTER 1: GETTING STARTED 1
A Quick Introduction to ASP.NET MVC 1
How ASP.NET MVC Fits in with ASP.NET 2
The MVC Pattern 2
MVC as Applied to Web Frameworks 3
The Road to MVC 5 3
MVC 4 Overview 6
Open-Source Release 10
ASP.NET MVC 5 Overview 11
One ASP.NET 11
New Web Project Experience 12
ASP.NET Identity 12
Bootstrap Templates 13
Attribute Routing 14
ASP.NET Scaffolding 14
Authentication Filters 15
Filter Overrides 15
Installing MVC 5 and Creating Applications 16
Software Requirements for ASP.NET MVC 5 16
Installing ASP.NET MVC 5 16
Creating an ASP.NET MVC 5 Application 17
The New ASP.NET Project Dialog 18
The MVC Application Structure 24
ASP.NET MVC and Conventions 27
Convention over Configuration 28
Conventions Simplify Communication 29
Summary 29
CHAPTER 2: CONTROLLERS 31
The Controller's Role 31
A Sample Application: The MVC Music Store 34
Controller Basics 38
A Simple Example: The Home Controller 39
Writing Your First Controller 42
Parameters in Controller Actions 45
Summary 47
CHAPTER 3: VIEWS 49
The Purpose of Views 50
View Basics 50
Understanding View Conventions 54
Strongly Typed Views 55
How ViewBag Falls Short 55
Understanding ViewBag, ViewData, and ViewDataDictionary 57
View Models 58
Adding a View 60
The Razor View Engine 63
What Is Razor? 63
Code Expressions 64
HTML Encoding 66
Code Blocks 68
Razor Syntax Samples 68
Layouts 70
ViewStart 72
Specifying a Partial View 73
Summary 74
CHAPTER 4: MODELS 75
Modeling the Music Store 76
Scaffolding a Store Manager 80
What Is Scaffolding? 80
Scaffolding and the Entity Framework 82
Executing the Scaffolding Template 85
Executing the Scaffolded Code 92
Editing an Album 97
Building a Resource to Edit an Album 97
Responding to the Edit POST Request 101
Model Binding 103
The DefaultModelBinder 104
Explicit Model Binding 105
Summary 107
CHAPTER 5: FORMS AND HTML HELPERS 109
Using Forms 110
The Action and the Method 110
To GET or to POST? 111
HTML Helpers 114
Automatic Encoding 115
Making Helpers Do Your Bidding 115
Inside HTML Helpers 116
Setting Up the Album Edit Form 117
Adding Inputs 118
Helpers, Models, and View Data 124
Strongly Typed Helpers 126
Helpers and Model Metadata 127
Templated Helpers 127
Helpers and ModelState 128
Other Input Helpers 129
Html.Hidden 129
Html.Password 129
Html.RadioButton 129
Html.CheckBox 130
Rendering Helpers 130
Html.ActionLink and Html.RouteLink 131
URL Helpers 132
Html.Partial and Html.RenderPartial 133
Html.Action and Html.RenderAction 133
Summary 135
CHAPTER 6: DATA ANNOTATIONS AND VALIDATION 137
Annotating Orders for Validation 138
Using Validation Annotations 141
Custom Error Messages and Localization 146
Looking Behind the Annotat