This project is read-only.

MVC4 bug in Area registration


public class AreaTests : RouteTestsBase
    private RouteTester<AdminAreaRegistration> tester;

    public void PrepareRoutes()
        tester = new RouteTester<AdminAreaRegistration>();

    // Test methods snipped

Generates the following exception
Initialization method IndividualTT.Web.Tests.AreaTests.PrepareRoutes threw exception. System.ArgumentException: System.ArgumentException: The class supplied to the generic constructor must inherit from either HttpApplication or AreaRegistration..

However the area registration code is inheriting from the AreaRegistration class
public class AdminAreaRegistration : AreaRegistration
    public override string AreaName
            return "Admin";

    public override void RegisterArea(AreaRegistrationContext context)
            new { action = "Index", id = UrlParameter.Optional }


manzo wrote Oct 18, 2012 at 12:32 PM

I've fixed this issue in a fork:

Uses the new RouteConfig class that MVC 4 introduced instead of the RegisterRoutes method in Global.asax.

manzo wrote Oct 18, 2012 at 2:21 PM

Apologies, I committed the incorrect version of this. I've now updated the code, and it should work correctly.