Professional ASP.NET MVC 5

( 2 )


ASP.NET MVC insiders cover the latest updates to the technology in this popular Wrox reference

MVC 5 is the newest update to the popular Microsoft technology that enables you to build dynamic, data-driven websites. Like previous versions, this guide shows you step-by-step techniques on using MVC to best advantage, with plenty of practical tutorials to illustrate the concepts. It covers controllers, views, and models; forms and HTML helpers; ...

See more details below
$38.98 price
(Save 22%)$49.99 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (17) from $16.98   
  • New (12) from $16.98   
  • Used (5) from $17.69   


ASP.NET MVC insiders cover the latest updates to the technology in this popular Wrox reference

MVC 5 is the newest update to the popular Microsoft technology that enables you to build dynamic, data-driven websites. Like previous versions, this guide shows you step-by-step techniques on using MVC to best advantage, with plenty of practical tutorials to illustrate the concepts. It covers controllers, views, and models; forms and HTML helpers; data annotation and validation; membership, authorization, and security.

  • MVC 5, the latest version of MVC, adds sophisticated features such as single page applications, mobile optimization, and adaptive rendering
  • A team of top Microsoft MVP experts, along with visionaries in the field, provide practical advice on basic and advanced MVC topics
  • Covers controllers, views, models, forms, data annotations, authorization and security, Ajax, routing, ASP.NET web API, dependency injection, unit testing, real-world application, and much more

Professional ASP.NET MVC 5 is the comprehensive resource you need to make the best use of the updated Model-View-Controller technology.

Read More Show Less

Product Details

  • ISBN-13: 9781118794753
  • Publisher: Wiley
  • Publication date: 8/4/2014
  • Edition number: 1
  • Pages: 624
  • Sales rank: 143,883
  • Product dimensions: 7.30 (w) x 9.20 (h) x 1.30 (d)

Meet the Author

Jon Galloway works at Microsoft as a Technical Evangelistfocused on ASP.NET MVC.

Brad Wilson has been a professional software developerfor more than 20 years, with 10 years in web development.

K. Scott Allen is the founder of OdeToCode LLC, whichprovides custom development, consulting, and mentoring services forclients worldwide.

David Matson is a software developer at Microsoft. He ispart of the MVC 5 and Web API 2 product team.

Read More Show Less

Table of Contents




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


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


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


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


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


Annotating Orders for Validation 138

Using Validation Annotations 141

Custom Error Messages and Localization 146

Looking Behind the Annotation Curtain 147

Controller Actions and Validation Errors 148

Custom Validation Logic 150

Custom Annotations 150

IValidatableObject 154

Display and Edit Annotations 155

Display 155

ScaffoldColumn 156

DisplayFormat 156

ReadOnly 157

DataType 157

UIHint 158

HiddenInput 158

Summary 158


Security: Not fun, But Incredibly Important 159

Using the Authorize Attribute to Require Login 162

Securing Controller Actions 162

How AuthorizeAttribute Works with Forms Authentication and theAccountController 167

Windows Authentication 169

Using AuthorizeAttribute to Require Role Membership 172

Extending User Identity 174

Storing additional user profile data 174

Persistance control 174

Managing users and roles 175

External Login via OAuth and OpenID 175

Registering External Login Providers 176

Configuring OpenID Providers 178

Configuring OAuth Providers 180

Security Implications of External Logins 181

Understanding the Security Vectors in a Web Application 182

Threat: Cross-Site Scripting 183

Threat: Cross-Site Request Forgery 193

Threat: Cookie Stealing 197

Threat: Over-Posting 200

Threat: Open Redirection 202

Proper Error Reporting and the Stack Trace 207

Using Configuration Transforms 208

Using Retail Deployment Configuration in Production 209

Using a Dedicated Error Logging System 209

Security Recap and Helpful Resources 209

Summary 211


jQuery 214

jQuery Features 214

Unobtrusive JavaScript 218

Using jQuery 219

Ajax Helpers 225

Adding the Unobtrusive Ajax Script to Your Project 225

Ajax ActionLinks 226

HTML 5 Attributes 230

Ajax Forms 230

Client Validation 233

jQuery Validation 233

Custom Validation 236

Beyond Helpers 241

jQuery UI 242

Autocomplete with jQuery UI 243

JSON and Client-Side Templates 246

Bootstrap Plugins 251

Improving Ajax Performance 253

Using Content Delivery Networks 253

Script Optimizations 253

Bundling and Minification 254

Summary 255


Uniform Resource Locators 258

Introduction to Routing 259

Comparing Routing to URL Rewriting 259

Routing Approaches 260

Defining Attribute Routes 260

Defining Traditional Routes 271

Choosing Attribute Routes or Traditional Routes 280

Named Routes 280

MVC Areas 282

Catch-All Parameter 284

Multiple Route Parameters in a Segment 285

StopRoutingHandler and IgnoreRoute 286

Debugging Routes 286

Inside Routing: How Routes Generate URLs 288

High-Level View of URL Generation 288

A Detailed Look at URL Generation 289

Ambient Route Values 291

More Examples of URL Generation with the Route Class 293

Inside Routing: How Routes Tie Your URL to an Action 294

The High-Level Request Routing Pipeline 294

RouteData 295

Custom Route Constraints 295

Using Routing with Web Forms 296

Summary 297


Introduction to NuGet 299

Adding a Library as a Package 301

Finding Packages 301

Installing a Package 303

Updating a Package 308

Package Restore 308

Using the Package Manager Console 309

Creating Packages 312

Packaging a Project 313

Packaging a Folder 313

Configuration File and Source Code Transformations 314

NuSpec File 315

Metadata 316

Dependencies 317

Specifying Files to Include 318

Tools 319

Framework and Profile Targeting 322

Prerelease Packages 324

Publishing Packages 325

Publishing to 325

Using NuGet.exe 327

Using the Package Explorer 330

Summary 332


Defining ASP.NET Web API 334

Getting Started with Web API 335

Writing an API Controller 335

Examining the Sample ValuesController 335

Async by Design: IHttpController 336

Incoming Action Parameters 340

Action Return Values, Errors, and Asynchrony 340

Configuring Web API 342

Configuration in Web-Hosted Web API 343

Configuration in Self-Hosted Web API 343

Adding Routes to Your Web API 346

Binding Parameters 347

Filtering Requests 349

Enabling Dependency Injection 350

Exploring APIs Programmatically 350

Tracing the Application 352

Web API Example: ProductsController 352

Summary 354


Understanding and Setting Up AngularJS 356

What’s AngularJS? 356

Your Goal in This Chapter 356

Getting Started 357

Adding AngularJS to the Site 359

Setting Up the Database 361

Building the Web API 363

Building Applications and Modules 364

Creating Controllers, Models, and Views 365

Services 368

Routing 371

Details View 373

A Custom MovieService 375

Deleting Movies 377

Editing and Creating Movies 379

Summary 384


Software Design Patterns 385

Design Pattern: Inversion of Control 386

Design Pattern: Service Locator 388

Design Pattern: Dependency Injection 392

Dependency Resolution in MVC 395

Singly Registered Services in MVC 397

Multiply Registered Services in MVC 397

Arbitrary Objects in MVC 399

Dependency Resolution in Web API 402

Singly Registered Services in Web API 402

Multiply Registered Services in Web API 403

Arbitrary Objects in Web API 405

Dependency Resolvers in MVC vs. Web API 405

Summary 405


Understanding Unit Testing and Test-Driven Development 408

Defining Unit Testing 408

Defining Test-Driven Development 410

Building a Unit Test Project 412

Examining the Default Unit Tests 413

Test Only the Code You Write 415

Advice for Unit Testing Your ASP.NET MVC

and ASP.NET Web API Applications 415

Testing Controllers 416

Testing Routes 420

Testing Validators 423

Summary 427


Extending Models 430

Turning Request Data into Models 430

Describing Models with Metadata 436

Validating Models 438

Extending Views 442

Customizing View Engines 442

Writing HTML Helpers 444

Writing Razor Helpers 445

Extending Controllers 446

Selecting Actions 446

Filters 447

Providing Custom Results 457

Summary 458


Mobile Support 461

Adaptive Rendering 462

Display Modes 470

Advanced Razor 473

Templated Razor Delegates 473

Advanced View Engines 476

Configuring a View Engine 477

Finding a View 478

The View Itself 479

Alternative View Engines 480

New View Engine or New ActionResult? 482

Advanced Scaffolding 482

Introducing ASP.NET Scaffolding 482

Customizing Scaffold Templates 483

Custom Scaffolders 485

Advanced Routing 486

RouteMagic 486

Editable Routes 487

Advanced Templates 492

The Default Templates 492

Custom Templates 496

Advanced Controllers 498

Defining the Controller: The IController Interface 498

The ControllerBase Abstract Base Class 499

The Controller Class and Actions 500

Action Methods 502

The ActionResult 502

Action Invoker 511

Using Asynchronous Controller Actions 515

Summary 520


May the Source Be with You 522

WebActivator 526

ASP.NET Dynamic Data 527

Exception Logging 530

Profiling 532

Data Access 535

EF Code–Based Migrations 536

Deployments with Octopus Deploy 539

Automated Browser Testing with Fluent Automation 540

Other Useful NuGet Packages 541

WebBackgrounder 541

Lucene.NET 542

AnglicanGeek.MarkdownMailer 543

Ninject 543

Summary 544


ASP.NET MVC 5.1 Release Description 545

Getting MVC 5.1 546

Upgrading MVC 5 Projects from MVC 5.1 546

Upgrading an MVC 5 Application to 5.1 547

Enum Support in ASP.NET MVC Views 549

Attribute Routing with Custom Constraints 553

Route Constraints in Attribute Routing 554

ASP.NET MVC 5.1 Example: Adding a Custom LocaleRoute 554

Bootstrap and JavaScript Enhancements 558

EditorFor Now Supports Passing HTML Attributes 558

Client-Side Validation for MinLength and MaxLength 561

Three Small but Useful Fixes to MVC Ajax Support 562

Summary 563


Read More Show Less

Customer Reviews

Average Rating 4.5
( 2 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 2 Customer Reviews
  • Anonymous

    Posted January 20, 2015


    ((Sorreh, busy! Birthday on Friday :3)) Vengence nuzzled her with an amused purr. ((Meh, school, bbl))

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted January 20, 2015


    [Happeh early birthday!] She smiled.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 2 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)