Razor intellisense无法与自定义ASP.NET MVC构建一起使用 [英] Razor intellisense not working with custom ASP.NET MVC build

查看:64
本文介绍了Razor intellisense无法与自定义ASP.NET MVC构建一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够创建一个自定义版本的ASP.NET MVC并将其在Web应用程序中使用,但是,我似乎无法弄清楚如何使Razor intellisense正常工作.

I was able to create a custom build of ASP.NET MVC and use it in a web application, however, I can't seem to figure out how to get the Razor intellisense to work correctly.

如果您按照以下步骤操作,则Razor intellisense将仅显示网页信息,而不会显示其他信息(HTML帮助器等).

If you follow the steps below, the Razor intellisense will only show WebPages info and nothing else (HTML helpers etc.).

我正在使用VS 2012.

I'm using VS 2012.

这是我到目前为止所做的:

Here's what I've done so far:

  1. 我克隆了最新的 ASP.NET Web Stack
  2. 打开Runtime.sln并构建解决方案
  3. 创建了一个新的ASP.NET MVC 4(.NET 4.0)Web应用程序
  4. 在步骤#2中删除了System.Web.MvcSystem.Web.RazorSystem.Web.WebPagesSystem.Web.WebPages.RazorSystem.Web.WebPages.Deployment的现有引用,并向已建立的程序集添加了引用.
  5. ~/Views/Web.config中,将System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35替换为System.Web.WebPages.Razor
  6. 此外,仅将System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35替换为System.Web.Mvc
  7. web.config

  1. I cloned the latest ASP.NET Web Stack
  2. Opened the Runtime.sln and built the solution
  3. Created a new ASP.NET MVC 4 (.NET 4.0) web application
  4. Deleted existing references for System.Web.Mvc, System.Web.Razor, System.Web.WebPages, System.Web.WebPages.Razor, System.Web.WebPages.Deployment and added references to the built assemblies in step #2.
  5. In ~/Views/Web.config, replaced System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 with just System.Web.WebPages.Razor
  6. Also, replaced System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 with just System.Web.Mvc
  7. Removed the following from the web.config

<runtime>
    <assemblyBinding xmlns="urn:schemasmicrosoftcom: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="1.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>

推荐答案

如果您要在VS 2012中寻找视图的智能感知支持,以及controllers文件夹和views文件夹的右键单击上下文菜单(添加控制器并添加视图),则需要打开Web项目的.csproj文件并手动对其进行编辑,以包括MVC项目类型GUID.这就是VS实际用来决定您所获得的智能感知风格(以及其他方面)的原因.

If you're looking for intellisense support in VS 2012 for views, as well as the right-click context menus for the controllers folder and views folder (shortcuts to add controller and add view) then you need to open up the .csproj file of your web project and manually edit it to include the MVC project type GUID. This is what VS actually uses to decide what flavor of intellisense you get (among other things).

具体来说,您要查找的.csproj文件的xml标记是:

Specifically, the xml tag of the .csproj file you're looking for is:

<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

您应该缺少GUID值

{E3E379DF-F4C6-4180-9B81-6769533ABE47}

祝你好运!

这篇关于Razor intellisense无法与自定义ASP.NET MVC构建一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆