Hi currently I am on a project of an api that render a cshtml template localy for reporting purpose. The issue is that when using the cdn link of bootstrap the cshtml is rendered acordinly but when using static css file locally all the style is not applied. I have looked on the web and found that you need to use static file middleware in the startup.cs but its not working either.
Here is the screenshoot of my directory:
and here is the code I added in the configure method:
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"StaticFiles")),
RequestPath = "/StaticFiles"
});
and here is a sample of the code loading the css in cshtml file:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>@Model.title</title>
@*<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>*@
<link href="grafana.light.min.css" rel="stylesheet" />
<link rel="stylesheet" href="bootstrap.min.css"/>
</head>
Does anyone have a fix for this? Kind Regards
Update:
Directory.GetCurrentDirectory() return the folowing path:
andh the folder where the project is located:
For confidentiality purpose I had to mask the name of the folder but I can testify its the same folder.