本文介绍了区不使用MvcExtensions在MVC 4显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我不知道是否MVC 4的工作方式不同,以MVC 3,但与MvcExtensions使用时,我的区域不显示在所有。在code以下是我如何用它在我的MVC 3应用程序。我刚才复制和粘贴文本到我的MVC 4应用程序。如果我使用的MVC 4应用程序附带的默认的Global.asax.cs文件,然后我区正确显示。必须在此可以做不同?

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?

我更换了的Global.asax.cs文件看起来是这样的:

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 FluentValidationBootstrapper 是我的自定义引导程序类。

RegisterRoutesBootstrapper, AutoMapperBootstrapper and FluentValidationBootstrapper are my custom bootstrapper classes.

推荐答案

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

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

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

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.

这篇关于区不使用MvcExtensions在MVC 4显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 17:24