Tag Helpers disabled in VS 2015
Asked Answered
E

4

5

I am having trouble getting Tag Helpers enabled in my project.

Here is a summary of the project setup:

  • VS 2015 RC Community Edition.
  • Project.json reference: Microsoft.AspNet.Mvc": "6.0.0-beta4
  • _GlobalImport.chtml has @addTagHelper"*,Microsoft.AspNet.Mvc.TagHelpers"

No build errors or warnings.

Must missing something, but I don't know what.

UPDATE:

Seems I am part of the way there. I added @addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers" to the _ViewStart.chtml. Razor is now processing things like <a asp-controller="Home" asp-action="Summary" title="Manage">TEST</a> as a link with a proper href attribute. However intellisense on not working.

Equites answered 21/6, 2015 at 14:11 Comment(1)
See Authoring taghelpers bit.ly/1Mqd0thMisspell
A
3

1) In your project.json dependencies, make sure you have these 3:

"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
  "version": "1.0.0-preview2-final",
  "type": "build"
},

2) In your project.json tools, make sure you have:

"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final"

3) In Your Views\_ViewImports.cshtml, make sure you have:

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Then rebuild the project and you should be good to go. (If not try restarting VS.)

Adze answered 20/10, 2016 at 6:37 Comment(1)
I setting this response as an answer since it's reflects how I am setting up my projects currently. But the truth is I have not experienced this issue in some time.Equites
E
3

After much back and forth I got the intellisense working.

As mentioned in the question update, I needed to add @addTagHelper "Microsoft.AspNet.Mvc.TagHelpers"

Finally, I looked at the NuGet page for tag helpers. I noticed some listed dependencies were not in my project. I added those, restarted VS, and got some intellisense.

Equites answered 28/6, 2015 at 11:26 Comment(3)
How about steps for this last comment.Boycie
@Sam, The question may be moot at this point. When I asked, I was using 1.0.0-beta5. I have not experienced this issue with the very latest ASP.Net and VS 2015 versions.Equites
Adding @addTagHelper "Microsoft.AspNet.Mvc.TagHelpers" to _ViewImports.cshtml is what got it working for me. Thanks!Boycie
B
3

Try to add dependency "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5" to your project.json.

That fixed a similar issue for me.

Brathwaite answered 5/10, 2015 at 6:3 Comment(2)
That and a restart of VS. Rebuilding alone isn't enough.Aminta
The restart did it.Neglect
A
3

1) In your project.json dependencies, make sure you have these 3:

"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
  "version": "1.0.0-preview2-final",
  "type": "build"
},

2) In your project.json tools, make sure you have:

"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final"

3) In Your Views\_ViewImports.cshtml, make sure you have:

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Then rebuild the project and you should be good to go. (If not try restarting VS.)

Adze answered 20/10, 2016 at 6:37 Comment(1)
I setting this response as an answer since it's reflects how I am setting up my projects currently. But the truth is I have not experienced this issue in some time.Equites
F
0

In my case I needed to deactivate the IntelliSense of ReSharper (9.2) which overrides the TagHelpers.

See: https://mcmap.net/q/858192/-mvc-6-tag-helpers-intellisense

Forefoot answered 17/11, 2016 at 9:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.