【问题标题】:.Cshtml is greyed out.cshtml 是灰色的
【发布时间】:2015-08-11 05:05:03
【问题描述】:

我在 VS2010 的 MVC 4.0 中工作,.cshtm 看起来是灰色的,也没有显示智能感知。即使解决方案正在构建,也没有任何错误。有什么建议吗?

我的 Root Web 配置文件如下所示:-

 <?xml version="1.0" encoding="utf-8"?>
<!--
 For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-GatewaySupportTool-20150810125527;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<pages>
  <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
  </namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers></system.webServer>
<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>
<entityFramework>
<defaultConnectionFactory    type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
  </configuration>

【问题讨论】:

  • 您确定您使用的是 Razor 视图引擎吗?
  • 是的,我正在使用 Razor..:)
  • 在你的应用设置中检查它是否是这样的
  • 有两个 webconfig 文件,首先驻留在 Views 中(它不包含您上面提到的密钥)。其次是根网络配置,它确实包含上述​​密钥。
  • 您能否将您的根 web.config 文件发布到您的问题中,让我们看看它!

标签: asp.net-mvc visual-studio-2010 asp.net-mvc-4 razor model-view-controller


【解决方案1】:

当您有自动更新的 Visual Studio将项目迁移到新版本的平台或 IDE 时,会出现此类问题。特别是,当您提到它没有显示智能感知并且我们有解析器错误基于 IDE 或项目配置中的一些更改以完美地相互配合时,这是正确的。 p>

当您第一次在安装了 VS 2008 的机器上运行 VS 2010 时,它会询问您是否要导入现有的 VS 2008 配置文件设置。默认情况下,此复选框已选中 - 这意味着默认情况下您会自动导入现有设置。

解决方案

  1. 尝试使用与您创建此项目相同的 IDE
  2. 尝试重新安装IDE
  3. 查看This 了解如何更正不需要的更改
  4. 使用Tools->Options菜单命令,选择Text Editor->C# 设置,然后选中上面带圆圈的两个复选框 (自动列出成员和参数信息)。智能感知将 然后开机并正常工作。

我想解决这个问题。

【讨论】:

    【解决方案2】:

    最后我通过安装 Microsoft Visual Studio 2010 Service Pack 1(安装程序)解决了这个问题。 请导航至链接http://www.microsoft.com/en-in/download/details.aspx?id=23691 下载并安装。安装后,打开 Visual Studio 看看问题解决了...:)

    【讨论】:

      猜你喜欢
      • 2019-12-13
      • 1970-01-01
      • 2019-06-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-30
      • 2021-06-23
      • 2011-07-13
      • 2012-11-11
      相关资源
      最近更新 更多