2012-07-27 39 views
0

我使用的是ASP.NET MVC 4 RC和最新版本的MvcExtensionsMvcExtensions.Autofac使用MvcExtensions在MVC 4中不显示的区域

我不知道MVC 4是否与MVC 3的工作方式不同,但是当与MvcExtensions一起使用时,我的区域根本不显示。下面的代码是我在MVC 3应用程序中使用它的方式。我刚刚复制并粘贴到我的MVC 4应用程序。如果我使用MVC 4应用程序附带的默认Global.asax.cs文件,那么我的区域将正确显示。这必须以不同方式完成吗?

我取代的Global.asax.cs文件看起来像这样:

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(); 
    } 
} 

RegisterRoutesBootstrapperAutoMapperBootstrapperFluentValidationBootstrapper是我的自定义引导程序类。

回答

1

我刚刚用MvcExtensions(v2.5.0)和自定义区域创建了一个测试Mvc4应用程序。一切工作正常我。

请确保您有bindingRedirects在根web.config文件:

<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> 

没有这些绑定重定向地区将无法正常工作。