如何更改 visual studio 中的默认网站图标?

How to chage default website icon in visual studio?

我需要更改此图标:

我已经更改了项目属性中的图标,并继续构建项目:

但图标没有改变。我还需要做什么吗?

But the icon doesn't change. Is there anything else I need to do?

如果你想在properties中设置图标。请确保你的项目中只有一个.ico文件名为favicon ,然后构建 project.You 需要在浏览器中同时按下 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>