In this appendix, some tips and tricks for building a real-life ASP.NET MVC application were covered, using the CarTrackr sample application, by zooming in on certain aspects that make developing ASP.NET MVC applications easier and faster. Using LINQ to SQL in a flexible manner, combined with the repository design pattern and dependency injection, provides the application with a flexible manner for coping with future requirements, and facilitates easier unit testing using mock data sources.
The ASP.NET MVC framework uses the ASP.NET provider model: authentication, authorization, membership, and session data. Developers can re-use ASP.NET code based on the provider model in ASP.NET MVC applications. In the CarTrackr application, a custom sitemap provider is developed and used as the default sitemap provider for standard ASP.NET controls.
CarTrackr uses the ASP.NET MVC Membership Starter Kit project to provide OpenID authentication on the login page.
Server-side form validation scenarios were explained by using an EnsureValid
method on the domain objects. This method provides a list of possible error messages, which can be mapped to the ModelState
dictionary of ViewData
and used in the view for displaying error messages.