查看类库// Razor Intellisense

Gla*_*lad 6 intellisense razorgenerator asp.net-mvc-5 razor-3

我想创建一个可用的View类库,包括使用Razor的视图.在我的观点中,我很难实现Razor Intellisense.

我已经做了很多研究来寻找解决方案,包括这个博客:http: //blogs.msdn.com/b/webdev/archive/2011/01/20/how-to-get-razor-intellisense-for -model-in-a-class-library-project.aspx和这个相关的帖子:类库中的Razor,缺少intellisense,但到目前为止没有任何工作.

我尝试的最后一件事是在我的View类库中添加了一个web.config文件,但这并没有启用Razor Intellisense.

web.config中:

<?xml version="1.0"?>
<configuration>

  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.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=5.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.webServer>
    <handlers>
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

当我创建一个MVC项目而不是类库来包含我的视图时,一切都有效...但我相信这是一件错误的事情.我已经有一个MVC项目,它只包含我的控制器,以及一个包含我的模型的类库.

有没有人对这个问题有所了解?