我怎样才能让超棒的字体图标显示在 Asp.Net Core Identity 中的帐户管理页面上?

How can I get font awesome icons to show up on the pages for account management in Asp.Net Core Identity?

在我的应用程序的主 _Layout.cshtml 中,我正在链接到 Font Awesome 样式表:

<link rel="stylesheet" href="~/lib/fontawesome/css/all.css" />

...图标出现在我期望的位置。除了身份下有关帐户管理的剃刀页面。

用于帐户管理的 _Layout.cshtml 文件位于 /Areas/Identity/Pages/Account/Manage。它不包含 <html><head><body> 标签,因此没有地方可以添加 <link rel...。但是,如果我添加这些标签,我就能让图标工作,但这会导致一组嵌套的标签,这是一个棘手的解决方法。

图标 显示在这些文件(以及其他文件)中:

Areas/Identity/Pages/Account/Register.cshtml
Areas/Identity/Pages/Account/Login.cshtml

在这些(以及其他)中:

Areas/Identity/Pages/Account/Manage/Index.cshtml
Areas/Identity/Pages/Account/Manage/Email.cshtml

如何在没有 "hacking" 的情况下使其对 ../Manage/ 中的文件起作用?

The _Layout.cshtml-file for account management sits in /Areas/Identity/Pages/Account/Manage.

It does not contain , or -tags, so there's no place there to add a <link rel....

要添加对 fontawesome css 文件的引用,您可以直接 link 为 Account/Manage/_Layout.cshtml 页面中 fontawesome 图标的 sheet 文件添加样式,如下所示。

@{
    Layout = "/Areas/Identity/Pages/_Layout.cshtml";
}

<link href="~/fontawesome/css/all.css" rel="stylesheet" />

<h1>Manage your account</h1>

<div>
    <h4>Change your account settings</h4>
    <hr />
    <div class="row">
        <div class="col-md-3">
            <partial name="_ManageNav" />
        </div>
        <div class="col-md-9">
            @RenderBody()
        </div>
    </div>
</div>

@section Scripts {
    @RenderSection("Scripts", required: false)
}

此外,如果您也像上面那样将/Areas/Identity/Pages/_Layout.cshtml指定为Account/Manage/_Layout.cshtml的布局页面,那么在/Areas/Identity/Pages/_Layout.cshtml页面的部分添加对~/fontawesome/css/all.css的引用也可以。

测试结果