[英]Asp.Net Core 6 Add Bootstrap to scaffolded Identity _Layout.cshtml
我正在使用 VS2022 預覽版,並使用 Angular 和 VS2022 中的默認項目創建了一個單頁應用程序。 我搭建了身份頁面的腳手架,以便我可以通過使用 Bootswatch 中的一個覆蓋引導程序來更改 styles。 但是,當我嘗試從 wwwroot 中的 lib 文件夾中引用 bootstrap 時,如下所示:
<link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.min.css" />
然后我得到錯誤:
Refused to apply style from 'https://localhost:5002/lib/bootstrap/css/bootstrap.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
我在這里嘗試了各種文件路徑,但似乎沒有任何效果。 任何幫助都會很棒,因為這似乎是一項微不足道的任務!
_Layout.cshtml
頁面是Scaffolded Identity生成的吧?
如果是這種情況,Identity package 還包含 Bootstrap 引用,默認情況下_Layout.cshtml
頁面已經使用以下代碼添加了 bootstrap 引用,您可以考慮使用它作為解決方法。
<link rel="stylesheet" href="~/Identity/lib/bootstrap/dist/css/bootstrap.min.css" />
結果如下:
此外,您還可以嘗試使用 CDN 參考:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
請將您的 lib 文件夾移動到 wwwroot 文件夾並從那里引用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.