ASP.NET MVC 4 in Action

ASP.NET MVC 4 in Action

Jeffrey Palermo, Jimmy Bogard, Eric Hexter

Language: English

Pages: 440

ISBN: 1617290416

Format: PDF / Kindle (mobi) / ePub


Summary

ASP.NET MVC 4 in Action is a fast-paced tutorial designed to introduce ASP.NET MVC to .NET developers and show how to apply it effectively. All examples in this revised edition are based on ASP.NET MVC 4, so you'll get full coverage of features such as the Razor view engine, Web Matrix helpers, and improved extensibility. You'll see how your ASP.NET applications can benefit from changes in the .NET Framework.

About the Technology

ASP.NET MVC provides the architecture needed to separate an application's logic and its UI. Because each component's role is well defined, MVC applications are easy to test, maintain, and extend. The latest version, ASP.NET MVC 4, takes advantage of .NET 4 and includes powerful features like the Razor view engine, Web Matrix helpers, and enhanced extensibility.

About the Book

ASP.NET MVC 4 in Action is a hands-on guide that shows you how to apply ASP.NET MVC effectively. After a high-speed ramp up, this thoroughly revised new edition explores each key topic with a self-contained example so you can jump right to the parts you need. Based on thousands of hours of real-world experience, the authors show you valuable high-end techniques you won't find anywhere else. Written for developers, the book arms you with the next-level skills and practical guidance to create compelling web applications.

You need some knowledge of ASP.NET and C#, but no prior ASP.NET MVC experience is assumed.

Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.

What's Inside

  • Complete coverage of ASP.NET MVC 4
  • The new Web API
  • Full-system testing

About the Authors

Jeffrey Palermo, Jimmy Bogard, Eric Hexter, Matthew Hinze, and Jeremy Skinner are all ASP.NET MVPs, ASP insiders, and early adopters of ASP.NET MVC.

=======================================

Table of Contents

    PART 1 HIGH-SPEED FUNDAMENTALS
  1. Introduction to ASP.NET MVC
  2. Hello MVC world
  3. View fundamentals
  4. Action-packed controllers
  5. PART 2 WORKING WITH ASP.NET MVC
  6. View models
  7. Validation
  8. Ajax in ASP.NET MVC
  9. Security
  10. Controlling URLs with routing
  11. Model binders and value providers
  12. Mapping with AutoMapper
  13. Lightweight controllers
  14. Organization with areas
  15. Third-party components
  16. Data access with NHibernate
  17. PART 3 MASTERING ASP.NET MVC
  18. Extending the controller
  19. Advanced view techniques
  20. Dependency injection and extensibility
  21. Portable areas
  22. Full system testing
  23. Hosting ASP.NET MVC applications
  24. Deployment techniques
  25. Upgrading to ASP.NET MVC 4
  26. ASP.NET Web API

 

 

 

 

 

 

 

 

 

 

 

 

 

depth—we’ll examine how ASP.NET MVC renders views and look at the different options available for passing data to views. Finally, we’ll cover the templating features that were originally introduced in ASP.NET MVC 2. To illustrate these features, we’ll begin to look at adding an edit page to the Guestbook application. 3.1 Introducing views The view’s responsibility can be deceptively simple. Its goal in life is to take the model given to it and use that model to render content. Because the

FormatAttribute DataTypeName System.ComponentModel.DataAnnotations.DataType Attribute DisplayFormatString System.ComponentModel.DataAnnotations.Display FormatAttribute DisplayName System.ComponentModel.DataAnnotations.Display Attribute or System.ComponentModel.DisplayNameAttribute EditFormatString System.ComponentModel.DataAnnotations.Display FormatAttribute HideSurroundingHtml System.Web.Mvc.HiddenInputAttribute IsReadOnly System.ComponentModel.ReadOnlyAttribute or

strongly typed views and separated view models to increase the cohesion of your views. With the popularity of separated view models increasing, the concept of using templates to drive content from the metadata on these view models has became possible. With separated view models, you can now keep the view concerns of your application isolated from your domain model. Now that you understand how views work, we’ll explore the fundamentals of using controllers in chapter 4. Download from Wow! eBook

external dependencies can be easily swapped out (such as database or web service calls). In order to effectively test our GuestbookController, we’ll need to make a few modifications to allow for testability, but before we do this, let’s take a look at the default unit testing project that’s part of ASP.NET MVC. 4.3.1 Using the provided test project By default, when you create a new ASP.NET MVC project, Visual Studio provides an option for creating a unit test project (which you saw briefly in

forward slashes that are usually used to separate route parameters. In this case, the route is mapped to the NotFound action of an ErrorController: public class ErrorController : Controller { public ActionResult NotFound() { return new NotFoundResult(); } } When the NotFound action is invoked, we return an instance of the NotFoundResult that we built earlier in section 9.3.3. This action result sets the status code for the response to 404 and then renders a custom error page. This example is a

Download sample

Download