You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ASP.NET Core应用:如何移除登录页的“使用其他服务登录”提示

移除ASP.NET Core Identity登录/注册页的“Use another service to log in.”提示

情况1:已生成本地Identity视图文件

  • 找到项目里的Areas/Identity/Pages/Account/Login.cshtml和Register.cshtml文件
  • 打开文件后,定位到包含Use another service to log in.的代码块(通常包裹在<section>标签内),直接删掉整个section块,或者只移除<h3>Use another service to log in.</h3>这一行即可。示例代码块大致如下:
<section>
    <h3>Use another service to log in.</h3>
    <hr />
    @{
        if ((Model.ExternalLogins?.Count ?? 0) > 0)
        {
            foreach (var provider in Model.ExternalLogins)
            {
                <button type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
            }
        }
    }
</section>

情况2:使用默认Razor Class Library中的Identity视图

  • 先通过Visual Studio的「添加>新建脚手架项」,选择「Identity」,勾选登录和注册页面,把这些视图生成到本地项目中,之后按照情况1的步骤修改即可(默认类库的视图无法直接编辑,必须先scaffold到本地)

额外提示

如果完全不需要外部登录功能,还可以在Program.cs(.NET 6+)或Startup.cs(旧版本)里删掉添加外部登录提供者的代码,比如AddGoogle、AddMicrosoftAccount这类配置,这样即使视图里有相关代码,也不会渲染出任何外部登录内容。

内容的提问来源于stack exchange,提问作者DangerMouse

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 22:42:35