简体   繁体   中英

How to connect CSS file to ASP.NET Core's _Layout.cshtml?

@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Mvc.ViewEngines
@inject IWebHostEnvironment Environment
@inject ICompositeViewEngine Engine
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - MerchShop</title>
    
    <environment include="Development">
        <link rel="stylesheet" href="~/Identity/lib/bootstrap/dist/css/bootstrap.css" />
        <link rel="stylesheet" href="~/Identity/css/site.css" />
    </environment>
</head>

This is the _Layout.cshtml from ASP.NET Core 6.0 with react + individual accounts and I'm trying to change styles for identity pages, which uses this layout.

All the pages in Areas/Identity/Pages/Account and Pages/Shared/ and wwwroot/ I created with add new scaffoled item > identity (if you will try to generate them and you will get an error, add this NuGet package Microsoft.Microsoft.VisualStudio.Web.CodeGeneration.Core and update all the others).

So technically I didn't write a single line of code except update-database in package manager console in the beginning and still site.css changes nothing, so I don't know what to do.

BUT if I will remove a link to bootstrap.css , bootstrap will disappear from the page, so this link works - BUT if I will go to that file and remove all lines of code in it, it will still work just like before. I don't know what to do please help.

nvm i just had to create Identity/css folder in wwwroot...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM