2012-07-27 33 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> 

沒有這些綁定重定向地區將無法正常工作。