MVC 6 Tag Helpers Intellisense?

后端 未结 6 710
眼角桃花
眼角桃花 2020-12-06 05:53

Is there supposed to be Intellisense for the new asp- tag helpers in Razor/MVC 6? I was following along on one of Shawn Wildermuth\'s courses on Pluralsight and

相关标签:
6条回答
  • 2020-12-06 06:11

    Make sure you add "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final" to your project.json dependencies.

    You also need to add @addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers" to your _ViewImports.cshtml to make the tag helpers available in al your views.

    You can get more information at aspnet 5 documentation page

    0 讨论(0)
  • 2020-12-06 06:12

    You need to also have

    "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"
    },
    

    in your project.json dependencies, you can see all of the steps here: https://stackoverflow.com/a/40147096/550975

    0 讨论(0)
  • 2020-12-06 06:14

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

    Steps in the Visual Studio 2015 Menu:

    • Go to ReSharper -> Options... -> IntelliSense -> General
    • Check "Custom IntelliSense"
    • Except HTML I changed dropdown entries to "ReSharper"
    • Restart Visual Studio

    The cshtml Razor page TagHelpers are now no longer overridden by ReSharper IntelliSense.

    0 讨论(0)
  • 2020-12-06 06:21

    In my case it was ReSharper, disabling I get Intellisense back

    0 讨论(0)
  • 2020-12-06 06:21

    Another thing, ensure that @addTagHelper in _ViewImports.cshtml is unquoted, for example: @addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" ----not good

    @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers ---good

    This fixed mine...

    https://github.com/aspnet/Tooling/issues/484

    0 讨论(0)
  • 2020-12-06 06:23

    In my case, my project did not use the project.json, I use Visual Studio 2017 with the csproj file.

    I simply needed to install (Tools -> Extentions and Updates...) this tool for Visual Studio (Razor Language Services):

    After I did that, I restarted Visual Studio, it installed the tool and then I got the intellisense working.

    0 讨论(0)
提交回复
热议问题