properties
中设置图标,请确保项目中只有一个名为favicon
的.ico
文件,然后构建项目。你需要在浏览器中同时按下Ctrl
+F5
来刷新网站。.ico
文件位于wwwroot
文件夹中,所以我只需将以下代码添加到_Layout.cshtml
中:<head>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
//add this line..
<link rel="icon" type="image/png" href="~/YourIconName.ico" sizes="32x32">
</head>