Brendan Vogt
Brendan Vogt

Reputation: 26018

Areas not displaying in MVC 4 using MvcExtensions

I am using ASP.NET MVC 4 RC and the latest version of MvcExtensions and MvcExtensions.Autofac.

I don't know if MVC 4 works differently to MVC 3, but my areas aren't displaying at all when using it with MvcExtensions. The code below is how I used it in my MVC 3 application. I have just copied and pasted it into my MVC 4 app. If I use the default Global.asax.cs file that came with the MVC 4 application then my areas display properly. Must this be done differently?

I replaced the Global.asax.cs file to look like this:

public class MvcApplication : AutofacMvcApplication
{
     public MvcApplication()
     {
          Bootstrapper.BootstrapperTasks
               .Include<RegisterAreas>()
               .Include<RegisterControllers>()
               .Include<RegisterRoutesBootstrapper>()
               .Include<AutoMapperBootstrapper>()
               .Include<FluentValidationBootstrapper>();
     }

     protected override void OnStart()
     {
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

          base.OnStart();
     }
}

RegisterRoutesBootstrapper, AutoMapperBootstrapper and FluentValidationBootstrapper are my custom bootstrapper classes.

Upvotes: 0

Views: 311

Answers (1)

AlexBar
AlexBar

Reputation: 2036

I've just created a test Mvc4 app with MvcExtensions (v2.5.0) and with a custom area. Everything works fine for me.

Please make sure that you have bindingRedirects in your root web.config file:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
      <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
      <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
      <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

Without these binding redirects areas will not work.

Upvotes: 1

Related Questions