Developing ASP.NET MVC 4 Web Applications. Exam Ref 70-486

Developing ASP.NET MVC 4 Web Applications. Exam Ref 70-486Reviews
Author: William Penberthy
Pub Date: 2013
ISBN: 978-0-7356-7722-7
Pages: 386
Language: English
Format: PDF/EPUB
Size: 15 Mb


Prepare for Microsoft Exam 70-486—and help demonstrate your real-world mastery of developing ASP.NET MVC-based solutions. Designed for experienced developers ready to advance their status, Exam Ref focuses on the critical-thinking and decision-making acumen needed for success at the Microsoft Specialist level.
Focus on the expertise measured by these objectives:

  • Design the application architecture
  • Design the user experience
  • Develop the user experience
  • Troubleshoot and debug web applications
  • Design and implement security

This Microsoft Exam Ref:

  • Organizes its coverage by exam objectives.
  • Features strategic, what-if scenarios to challenge you.

Design the application architecture

ASP.NET pages raise and handle events between the browser and webpage, whereas ASP.NET MVC applications are organized around controllers and action methods. Action methods are typically one-to-one mappings to user interactions. Each user interaction creates and calls a uniform resource locator (URL). The routing engine parses the URL using routing…

Because action methods map to user interactions, an action method is called every time a user does something that interacts with the server. This is important to remember when you are approaching the design of your application. Historically, traditional web design has taken a paged approach, in which a set of features occurs on an individual page. ASP.NET Web Forms, for example, uses that methodology, in which the implementation logic for a page is handled on that page. Although this design makes some aspects of communicating between pages complicated, it acts as a built-in mechanism for managing the design. If you need to create a page for users to manage a widget, you can do that. Whenever a user needs to create a widget, you would redirect them to that page. With ASP.NET MVC, you need to take a different approach to design because there are no pages, just action methods.

One way to look at a controller is as a way to separate functionality. You could create a large, complex application with dozens of screens using a single controller. You can see a small example of this when you create a new ASP.NET MVC Internet project in Visual Studio (the default integrated development environment for ASP.NET MVC 4). The HomeController that is built as part of this project handles the views for the About, Contact, and Home pages by using an action for each page. A better approach when laying out the controller structure is to have a controller for each type of object with which the user will be interacting on the screen. This enables you to compartmentalize the functionality around the object into a single place, making code management simpler and providing more easily understandable URLs.


Both the Web Forms and the Razor view engines are derived from the BuildManagerViewEngine class, which is derived from the VirtualPathProviderViewEngine class. A common reason for overriding or replacing the default view engine classes is to deviate from the conventionbased design the standard view engines must follow. You can also write an HTML helper to help you generate HTML inside views. An HTML helper is a class that helps you create HTML controls programmatically. A helper generates HTML and returns the result as a string for inclusion in the response stream. You can create HTML and AJAX-HTML for inclusion in your view, or URL helpers, which help determine the appropriate route or URL that can be accessed from both the view and controller. You can also write a Razor helper using Razor syntax. Razor helpers are one of Razor’s unique features. They encapsulate blocks of HTML and server-side logic into reusable page-level methods.

Troubleshoot and debug web applications

Design an exception handling strategy

Exceptions are a standard part of applications. Even if your software is error free, your application can throw exceptions or experience other problems due to external factors, such as improper data input or network problems. As you design your ASP.NET MVC 4 application, you should consider potential problem points, such as calling a web service for data or accessing fies on a fie share, and determine what you will do when an error occurs. Also consider whether you will notify users and, if so, what you will display in a message. You also need to choose recovery options to keep your application in a normal running state and the kind of diagnostic information you should

Design and implement security

Creating custom membership providers

The flxibility of ASP.NET MVC (and its underlying framework ASP.NET) enables you to create new functionality if you need authentication and other security features that are not included in the framework’s membership features. Many developers try to put their code into the controller, but this is not very secure or flxible, especially with server caching and the way ASP.NET MVC manages the cache. It’s possible that your actions will be cached, and your application might become unsecure through daily use. A better way to manage customization is to use extensibility points in ASP.NET MVC and ASP.NET. Extensibility points were designed to allow customization by overriding current functionality to add additional business processing or through a complete replacement.

If you need to change the way ASP.NET MVC membership manages authentication, you usually inherit the AuthorizeAttribute class. If you need a different way to manage membership, change the underlying ASP.NET membership providers to better suit your requirements. The Windows authentication provider, ActiveDirectoryProvider, handles those cases in which login information is sent through the browser without user or developer intervention. If you need to modify how authentication works, you’ll likely be working with the SqlMembershipProvider because it is designed with extensibility in mind. The .NET Framework provides these two membership providers, assuming that your application will use Windows authentication or the more flxible Forms authentication with SqlMembershipProvider.