问题
I am having issues with .NET core and tag helpers. The color coding and the intellisense are not displaying or being registered when I type in asp-for. I've tried creating a new solution in a separate instance, verified that the intellisense works, and then copied the project.json into the project that doesn't have working intellisense/color coding, and it doesn't fix the issue.
Here is my project.json
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
}
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
I've also made the reference/injection in the _ViewImports file for the mvc tag helpers. This is the view where I'm testing that it works.
And here is my project structure, just in case you can see something that I'm not seeing.
If it helps at all, here is the version of Visual Studio I am using.
回答1:
I fixed it in two steps.
1.Install Razor tool from package manager console. It is pre-release for now
Install-Package Microsoft.AspNetCore.Razor.Tools –Pre
- Download and install Razor Language Services from marketplace. (Your visual studio instance should be closed)
After restart visual studio, intellisense and coloring should be working for tag helpers.
回答2:
This is a semi-old Q&A, but I recently solved a similar problem where tag helper intellisense and highlighting/colorization suddenly stopped working, so I post this for posterity.
I tried to repair and reinstall Visual Studio to no avail. What ultimately solved this issue follows:
Close all instances of Visual Studio.
Download and install the latest .NET Core SDK.
Open "Apps & features" (Add or remove programs)
Search for ".NET Core SDK" and uninstall all except the latest version (x64 and/or x86).
Reopen Visual Studio.
来源:https://stackoverflow.com/questions/40924211/net-core-tag-helper-intellisense-and-color-coding-not-working