I have a project that I am building with .NET Core 6. I have installed a bootstrap package via Libman, stored under "lib/twitter-bootstrap/css/bootstrap.css". I am having some problems linking to this file from the ‘_layout.cshtml’ file in my ‘Views/Shared’ folder. I wondered if anyone knows of the correct way to hyperlink.
Code of _layout.cshtml is below:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>SportsStore</title>
<link href="./twitter-bootstrap/css/bootstrap.css" rel="stylesheet" />
</head>
<body>
<div class="bg-dark text-white p-2">
<span class="navbar-brand ml-2">SPORTS STORE</span>
</div>
<div class="row m-1 p-1">
<div id="categories" class="col-3">
Put something useful here later
</div>
<div class="col-9">
@RenderBody()
</div>
</div>
</body>
</html>
Screenshot of folder structure of my .NET Core project:
I would be very grateful for any advice.
Thanks,
Robert
London, UK
2
Answers
Firstly,make sure you’ve called
app.UseStaticFiles()
in Program.cs.If you haven’t modifyed FileProvider ,create a folder named of "wwwroot" and move your static files into it.Also you could tryFor more details,you could check this document
Secondly,try with
If you moved the folder into wwwroot folder
You can try this :
(instead of : )