13.12. Extending MVC

ASP.NET MVC is very easy to customize and extend. You don't like how the view engine works? No problem—you can override it. ASP.NET MVC is a framework practically begging for customization.

13.12.1. Extension Methods

One of the easiest ways to extend the existing ASP.NET MVC functionality is by writing extension methods on some of the HtmlHelper classes. For example, you might need to render a home page link to a specific page throughout your application. To accomplish this, you can create an extension method.

Let's do so now. Create a new class called UrlHelperExtension.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Chapter13.BobsMoviesMVC.Controllers ...

Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.