0

I am developing my first .net core web application. I am trying to put my company logo in _layout.cshtml page, but it seems that the style sheet site.css is not recognized by the _layout page. Below is my code for _layout.cshtml page:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>@ViewData["Title"] - VitalRecords</title> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="~/css/site.css" /> </head> <body> <header> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <div class="headerDiv"> <div class="headerTopBanner"></div> <div class="headerLogo"> <div class="logo"></div> </div> <h1 class="display-4">Welcome</h1> </div> </nav> </header> <div class="container"> <main role="main" class="pb-3"> @RenderBody() </main> </div> <footer class="border-top footer text-muted"> <div class="container"> &copy; 2020 - test - <a asp-area="" asp-page="/Privacy">Privacy</a> </div> </footer> <script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> <script src="~/js/site.js" asp-append-version="true"></script> @RenderSection("Scripts", required: false) </body> </html> 

and my site.css has the following defined:

.headerDiv { background-color: white; } .headerTopBanner { background-color: $header-top-banner-color; height: 5px; width: 100%; } .headerLogo { padding: 5px; padding-left: 10px; vertical-align: middle; } .logo { background: url(../../images/LogoWithDesc) 0 0; min-height: 70px; vertical-align: middle; } $header-top-banner-color: #FD810A; 

the screen shot of the output looks like so:

enter image description here

I have the similar code in Index.cshtml:

@page @model IndexModel @{ ViewData["Title"] = "Home page"; } <div class="headerDiv"> <div class="headerTopBanner"></div> <div class="headerLogo"> <div class="logo"></div> </div> <h1 class="display-4">Welcome</h1> </div> 

Thats is why the welcome is coming twice on my page, but logo and some other colors are not coming. It seems that site.css is not recognized at all.

any help will be highly appreciated,

1 Answer 1

2

Try importing your css link like this

<link href="@Url.Content("~/css/site.css")" rel="stylesheet" type="text/css" /> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.