Visual Studio .net core tag helpers not working

asp.net core tag helpers not working in areas
asp.net core tag helpers vs html helpers
asp-action not working
label asp-for not working
list of asp net core tag helpers
blazor tag helper
found a malformed 'form' tag helper. tag helpers must have a start and end tag or be self closing
asp-items not working

Well, lets get down to it. I'm using Visual Studio 2015 and ASP.NET core tag helpers have completely stopped working, no idea why as I've not changed anything. I was in work one day, they worked fine, then I came in the next day and now no ASP.NET core web project at all shows any tag helpers!?! I've tried creating a fresh new ASP.NET core mvc project and they don't work there either!!! I'm completely stuck, is there some setting somewhere that completely turns them off in Visual Studio?

Note that I've checked everything that usually causes this problem according to most other posts. My _ViewImports has the line:-

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

and here is a complete project.json file from a fresh project I just created and made NO changes to at all:-

{
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net452": { }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Also, all the _Layout views and other views have completely lost their highlighting that used to appear. No one else I've found on the internet so far seems to be having this problem, don't suppose anyone else has any ideas?

EDIT:

One of the answers below has solved this for new projects in a new solution but I'm still having problems with existing solutions/projects. Here's the project file contents from one of these existing projects, hopefully someone can spot something here...

{
  "dependencies": {
    "BundlerMinifier.Core": "2.2.306",
    "Configuration.Web": "1.0.0-*",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.1.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools":  "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net452": {
      "dependencies": {
        "Aristotle.Service": {
          "target": "project"
        },
        "Infrastructure": {
          "target": "project"
        }
      }
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

I've updated all packages using NuGet to latest versions...

I've finally fixed this, but have no idea why the fixed works or why it stopped working in the first place but...

in _ViewImports the line which is:-

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

I've changed to include quotes:-

@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"

Then I did a rebuild and its working again!?! All the 'asp-' attributes are also now highlighted as they were before. Why?!? Eh?!?

Stranger still, if I remove the quotes and rebuild, it still works! Well, at least until my colleagues get the file out of source control, they have to put the quotes back in!!

Figure that one out...

How to fix Microsoft.AspNetCore.Mvc.TagHelpers not , In this video , I am going to show you how to fix tag helper rendering problem in asp.net core Duration: 1:21 Posted: 26 Jan 2020 The Visual Studio editor helps you write all of the markup in the Tag Helper approach of the register form, while Visual Studio provides no help for most of the code in the HTML Helpers approach. IntelliSense support for Tag Helpers goes into detail on working with Tag Helpers in the Visual Studio editor.

For anyone meet the same problem, please check the location of the _ViewImports.cshtml, It must be in the same folder of your Views. For example, I have created a project that already have the _ViewImports.cshtml file in Pages folder, but I create and use my view files located in another folder, so ASP.NET can't find the _ViewImports.cshtml for our views.

With anyone have issue finding the project.json, you can right click at the project and choose Manage Nuget Packages then install the Microsoft.AspNetCore.Mvc.TagHelpers.

Hope these advices can help everyone.

Tag Helpers in ASP.NET Core, Razor Tag helper Intellisense/highlighting not working. Closed - Fixed visual studio 2017 rcwindows 10.0intellisense · avatar image that the tag helpers in a ASP.Net Core project are not being recognized for Intellisense. ASP Core @html TagHelpers not working / highlighting .net visual studio 2019 version 16.5 Janrey Palaran reported Apr 08 at 05:56 AM

In your project.json dependencies, you are missing TagHelpers. Please add below line in dependencies section of project.json-

"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",

On saving Project.json, VS2015 automatically restore packages.

If it doesn't worked then right click on project and click on Restore Packages option.

If this doesn't worked then try restoring using dotnet restore CLI command.

How to fix Microsoft.AspNetCore.Mvc.TagHelpers not being , Middleware · Dependency Injection · Working With Forms NET Core framework includes a number of predefined tag helpers targeting many Note: The value provided to the @addTagHelper directive is not enclosed in quotes. The image below illustrates how Visual Studio shows enabled tag helpers  Based on the docs and other questions that have been answered on here, this should be sufficient to get Intellisense working for the tag helpers. Also, when I create a Web Application using the standard template in Visual Studio, the Intellisense works fine, so I am not sure what I am missing. Any ideas? Thanks in advance.

If you are experiencing the same problem when using Areas, add the _ViewImports file to the Views folder of your Area

Razor Tag helper Intellisense/highlighting not working, for ASP NET Core 1 none of the Tag helpers seem to light up and I do not get GitHub is home to over 50 million developers working together to host and --​info in the package manager console window in Visual Studio. Click on Online in the left column, and use the search box to locate "Razor Language Services." Install the extension and restart VS 2017. Once this is installed, you'll have full TagHelper IntelliSense. When the feature is rolled out in updates, the extension will be disabled for you.

I have this project.json for today:

{
  "dependencies": {
    "BundlerMinifier.Core": "2.4.337",
    "Microsoft.ApplicationInsights.AspNetCore": "2.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.2",
    "Microsoft.AspNetCore.Mvc": "1.1.3",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.1.3",
    "Microsoft.AspNetCore.Razor.Design": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Routing": "1.1.2",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.2",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.2",
    "Microsoft.AspNetCore.StaticFiles": "1.1.2",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.2",
    "Microsoft.Extensions.Configuration.Json": "1.1.2",
    "Microsoft.Extensions.Logging": "1.1.2",
    "Microsoft.Extensions.Logging.Console": "1.1.2",
    "Microsoft.Extensions.Logging.Debug": "1.1.2",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.1.1"
    },
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    //"Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.1.0-preview4-final",
    //"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.1.1",
    "Wallet.Core": "1.0.0-*"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final"
  },

  "frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "dnxcore50"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Tag helpers in Razor Pages, Updating them to asp net core 2.2 version seems to fix the problem. Did something ch Do the tag helpers light up in visual studio? Have you  You create a tag helper in this namespace and include the assembly name into the _ViewImports like this: *** @addTagHelper *, SUPER_TEST *** It's not gonna work. Because in fact your assembly is now called SUPER-TEST. .Net Core runtime replaces underscores with dashes when creating the new project.

TagHelpers not highlighted? · Issue #1475 · dotnet/aspnetcore , Tag Helper Components work in conjunction with Tag Helpers. Creating the Tag Helper Component: ArticleTagHelperComponent.cs. C# else has heard of issues with TagHelperComponenets not working with dotnet core 2 razor pages? Using the tag helper, we can extend our existing HTML elements or create our own custom HTML elements. The custom tag helper is nothing but the class that implements the ITagHelper interface. However, .NET Core MVC provides us the implementation of this interface.

Using 1.x tag helper in net core 3 · Issue #14378 · dotnet/aspnetcore , NET Core MVC and are C# classes that transform HTML elements in a The problem with HTML helper expressions is that they don't fit with  Few Tag Helpers actually act as elements or actual tags (environment, cache, etc.). They make working with HTML while using the power of Razor and C# so simple and HTML friendly. Since using Tag Helpers feels so natural and looks like regular HTML front-end people can also quickly jump in and change things without learning about C#.

ASP.NET Core MVC - Tag Helper Components, The Environment Tag Helper's single attribute, names, is a comma-separated list of environment names. If any of the provided environment names match the current environment, the enclosed content is rendered. For an overview of Tag Helpers, see Tag Helpers in ASP.NET Core. Environment Tag Helper Attributes names

Comments
  • I have found when I run into similar problems with .net core that updated my packages helps. It looks like you have a few packages that, even for 452 are at version 1.1. Maybe upgrade them in that test proj you created and see if it helps.
  • Update your project dependencies to latest stable release.
  • hi, thanks for the response, I've tried updating all packages to latest version and that has no effect unfortunately. However, creating a new project from scratch now works if I put the tag helper reference in (see other answer below). This doesn't work with all my existing projects however...
  • This was my problem. If you use Areas you need to make multiple dupes your _ViewImport file it seems. Add one to each Views folder
  • The _ViewImports.cshtml file affects all views in the same or descendant folders to where the _ViewImports.cshtml file is placed.
  • For me was the environment helper tag displayed all the enclosed content, regardless of the include value. So it looked like I had the typical double-value problem of Development and Production, when it was "simply" the helper tag was ignored, so its contents were always visible.
  • thanks, that's worked for new projects in a fresh solution. However it doesn't work for existing projects in existing solutions - whether they are v1.0.1 or have been upgraded to v1.1.0. I've tried other versions of the tag helper reference for the all projects but still no joy.
  • Do you receive any error? If it is problem with project.json then compare existing project.json vs fresh project.json.
  • @padigan Are you receiving any errors for existing project? what is the SDK version mentioned in your global.json?
  • Hi, its { "projects": [ "src", "test" ], "sdk": { "version": "1.0.0-preview2-003131" } }