zoukankan      html  css  js  c++  java
  • ASP.NET MVC 3.0 视图在类库项目中无法智能提示解决方法

    由于某种架构的需要,许多视图(.cshtml)被分布到不同的类库项目中,在项目编译时通过post-build复制到启动项的指定目录。部分开发人员在一些项目中修改视图时出现无法智能提示。Views文件夹下有Web.config,当打开某个.cshtml文件出现提示:“ASP.NET runtime error: There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in the machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.”。

    在项目根目录中添加Web.config,并复制如下内容:

    <configuration>
      <configSections>
        <sectionGroup name="system.web.webPages.razor"
                      type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="host"
                   type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
                   requirePermission="false" />
          <section name="pages"
                   type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
                   requirePermission="false" />
        </sectionGroup>
      </configSections>
    
      <system.web.webPages.razor>
        <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <pages pageBaseType="System.Web.Mvc.WebViewPage">
          <namespaces>
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
          </namespaces>
        </pages>
      </system.web.webPages.razor>
    
      <system.web>
        <compilation targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>
      </system.web>
    </configuration>
  • 相关阅读:
    Tomcat报错:Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/JFreeChartTest]]
    Md5 加密,加盐值
    ajax 分页 步骤和代码
    【每天学习一点点】numpy中的reshape中参数为-1
    smali文件语法参考
    google zxing 二维码扫描(android client分析)
    cygwin编译ffmpeg移植到android平台问题集锦
    Sequoyah 本机开发Native Development: Invalid path for NDK(路径无效) 解决方案
    优化模式--数据局部性
    程序猿,你也配吃10元的盒饭?
  • 原文地址:https://www.cnblogs.com/junchu25/p/2697617.html
Copyright © 2011-2022 走看看