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

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

问题描述

Intellisense在剃须刀文件中不起作用:

Intellisense does not work in razor files:

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

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>

推荐答案

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

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:

只需删除%LOCALAPPDATA%\Microsoft\VisualStudio\14.0\ComponentModelCache

如果您使用的是VS 2019,则版本文件夹名为16.0_<hash>.

If you're using VS 2019, the version folder is named 16.0_<hash>.

作为附加步骤,如果上述步骤不能解决问题,则可以选择在VS的Developer Command Prompt中运行命令DevEnv.exe /setup(以管理员身份).

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天全站免登陆