Search code examples
c#twitter-bootstrapasp.net-coreasp.net-core-tag-helpers

Taghelpers with Bootstrap 4


I'm trying to integrate Bootstrap 4 into my application. In my _Layout.cshtml file I have the following:

<link asp-href-include="~/lib/bootstrap/dist/css/bootstrap.min.css" asp-href-exclude="**/*-reboot*,**/*-grid*" rel="stylesheet" />

My bower configuration file:

{
  "name": "asp.net",
  "private": true,
  "dependencies": {
    "bootstrap": "~4.0.0"
  }
}

My _ViewImports.cshtml (in the /Views folder, not /Views/Shared folder) has

@addTaghelper *, Microsoft.AspNetCore.Mvc.Taghelpers

and I have _Layout.cshtml in my _ViewStart.cshtml file.

The bootstrap link doesn't seem to work when using the asp-href-include and asp-href-exclude taghelpers. The bootstrap layouts are not applied. When I use the basic

<link href="~/lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />

in my _Layout.cshtml, Bootstrap is applied but not in the layout I want. How can I integrate the taghelpers to get the desired design?


Solution

  • Stupid mistake, capitalizing the "H" in TagHelpers fixed it

    @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers