I have an issue with tag helpers. All I want to do is create a form that posts data to the controller - basic enough I thought but it doesnt work in my project.
I create a brand new asp.net core web application with default setup and it works there but my project refuses to recognise the tags and act accordingly. Notably the markup doesnt highlight the same or provide info when hovered over so some ref or something fundamental is missing, can anyone advise.
*Default project working with correct highlights
*My project - not highlighting the code right or working. Project.json is the exact same so I have no idea whats missing.
FOUND IT!
Microsoft like to change things. So, MVC 6 (asp.net core ...etc) can make use of a _ViewImports.cshtml
file in the views folder (feel free to add it yourself if you like me made a project before this existed).
This acts like global import file, and to make the tag helpers available in all your views, you need to add reference here.
Mine now looks like this:
@using Mobile.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
And boom - tags look correct and its work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With