0

我正在使用ASP.NET MVC 4 RC最新版本的MvcExtensionsand MvcExtensions.Autofac

我不知道 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();
     }
}

RegisterRoutesBootstrapperAutoMapperBootstrapper并且FluentValidationBootstrapper是我的自定义引导程序类。

4

1 回答 1

1

我刚刚使用 MvcExtensions (v2.5.0) 和自定义区域创建了一个测试 Mvc4 应用程序。一切对我来说都很好。

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

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

没有这些绑定重定向区域将无法工作。

于 2012-07-31T18:55:25.597 回答