Razor 文件 (.cshtml) 中的 IntelliSense 停止工作 [英] IntelliSense in Razor files (.cshtml) stopped working

查看:20
本文介绍了Razor 文件 (.cshtml) 中的 IntelliSense 停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Intellisense 在 razor 文件中不起作用:

在我的 web.conifg 文件(在 Views 文件夹中)显然是正确的:

</处理程序></system.webServer></配置>

解决方案

在 IntelliSense 突然开始出现错误并停止在我的视图中的 HTML 标记之间正确着色 C# 代码之后,这对我有用:


删除%LOCALAPPDATA%MicrosoftVisualStudio16.0_ComponentModelCache

文件夹中的内容即可

作为附加步骤,如果上述步骤不能解决问题,您可以选择在 VS 的开发人员命令提示符中运行命令 DevEnv.exe/setup(以管理员身份).>

Intellisense does not work in razor files:

In my web.conifg file (in the Views folder) is apparently correct:

<?xml version="1.0" encoding="utf-8"?>
<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" />
                <add namespace="System.Web.Optimization" />

                <add namespace="MvcSiteMapProvider.Web.Html" />
                <add namespace="MvcSiteMapProvider.Web.Html.Models" />

                <add namespace="DevTrends.MvcDonutCaching" />
            </namespaces>
        </pages>
    </system.web.webPages.razor>

    <appSettings>
        <add key="webpages:Enabled" value="false" />
    </appSettings>

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers>
            <remove name="BlockViewHandler" />
            <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
        </handlers>
    </system.webServer>
</configuration>

解决方案

This is what worked for me after IntelliSense suddenly began to bug out and stopped colouring C# code correctly in between the HTML tags in my views:


Just delete the contents of the folder at %LOCALAPPDATA%MicrosoftVisualStudio16.0_<hash>ComponentModelCache


As an additional step, you can optionally run the command DevEnv.exe /setup in Developer Command Prompt for VS (as an Administrator) if the above step doesn't resolve the issue.

这篇关于Razor 文件 (.cshtml) 中的 IntelliSense 停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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