.NET Core fundamentals in one picture.

How to fix Microsoft.AspNetCore.Mvc.TagHelpers not being rendered!

This post was most recently updated on January 17th, 2020.

Reading Time: 3 minutes.

Ha – another one, that ended up being a simple fix, but since nobody actually explains it well, took me an hour to figure out.

This post ended up being another example of my “I’m going to document every single fix, that took me more than 10 minutes to figure out, since that’ll help me (and others) the next time the same issue arises.” blogging strategy. Snappy name, right? Never was my strongest suit!

Anyway, I ended up banging my head to the wall. Hopefully after documenting this, you wouldn’t have to.

What are TagHelpers then?

I’m quoting and paraphrasing Microsoft for a while here, as they explain it pretty thoroughly:

Tag Helpers enable server-side code to participate in creating and rendering HTML elements in Razor files. There are many built-in Tag Helpers for common tasks – such as creating forms, links, loading assets and more – and even more available in public GitHub repositories and as NuGet packages.

Tag Helpers are authored in C#, and they target HTML elements based on element name, attribute name, or parent tag. For example, the built-in LabelTagHelper can target the HTML element when the LabelTagHelper attributes are applied.

An example of LabelTagHelper would be this:
<label asp-for=”Movie.Title”></label>

This built-in helper would fetch the name / display name for a property called Title on the object of type Movie on a view.

If you’re familiar with HTML Helpers, Tag Helpers reduce the explicit transitions between HTML and C# in Razor views. In many cases, HTML Helpers provide an alternative approach to a specific Tag Helper, but it’s important to recognize that Tag Helpers don’t replace HTML Helpers and there’s not a Tag Helper for each HTML Helper.


In short, they reduce the need for you to code menial, boring stuff, that nobody wants to do. That’s good stuff.

How to start using “Microsoft.AspNet.Mvc.TagHelpers”?

The bottom line is this – you need to add this line to your _ViewImports.cshtml file. And you need to make SURE, that the particular _ViewImports file is used for your views!

@using Microsoft.AspNetCore.Identity
@using YourApp
@namespace YourNamespace
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

So what was wrong in my case?

I had downloaded an example from Microsoft, and built on top of that. The sample was great, but not meant to familiarize the user with how routing works in ASP.NET Core – it was just expected to work. But suddenly, for me it stopped working, when I added another controller with views!

So what exactly didn’t work?

Code like below wouldn’t route anything anywhere. The anchor elements were not links at all.

<!-- Other stuff here -->
   <a asp-action="Edit" asp-route-id="@item.SiteId">Edit</a> |
   <a asp-action="Details" asp-route-id="@item.SiteId">Details</a> |
   <a asp-action="Delete" asp-route-id="@item.SiteId">Delete</a>
<!-- Other stuff continues -->

Why did this work on some Views, but not on others?

And how to fix that?

The fix ended up being simple – just copypaste a suitable _ViewImports.cshtml under your /Views -folder.

The _ViewImports.cshtml file is required in the folder your Views are in, or its parents. The example I was working with only included _ViewImports -files under /Pages and its subfolders.

Another things, that’s super simple when you know it, but frustrating when you’re picking something new up!

Further Reading


Leave a Reply

7 Comment threads
11 Thread replies
Most reacted comment
Hottest comment thread
8 Comment authors
Paul ThompsonRyanSudhanshu ShekharAjeetRoman Recent comment authors
Notify of

I have the issue with tag Helpers not being rendered. This is a POC application and I have tried the following

Installed the NuGet Package for Tag Helpers
Added @addTagHelper to _ViewImports file
Copied the _ViewImports to the View’s sub folder

None of these worked !


After a while I figured out the silly issue. The following statement should NOT have a semicolon at the end and I had one!

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Talha Rafique
Talha Rafique

great bro ! i love your explanation.


thank you this worked to me on my project asp net core on MAC, a lot of things has to be written from scratch one of them is build razor pages and that means create the “Pages” folder so into this folder those files were not added and any of the hyperlinks were working, after add _ViewImports.cshtml and _ViewStart.cshtml everything started working!


greate thanks

Sudhanshu Shekhar
Sudhanshu Shekhar

I had a similar issue and i struggled a lot for few hours wondering whats going wrong until i came up to this post and got the resolution. Thanks a lot !!