作为一个学期项目,我和朋友正在使用ASP.NET Core MVC中的Planning应用程序。我们已启用Facebook登录,但按钮相当简单,我希望能够更改注册与Facebook按钮的布局。
我们最近从ASP.NET Framework更改为Core,在Framework中我可以在名为_ExternalLoginListPartial.cshtml的文件中更改它。我在所有文件夹中查看过,但找不到与该文件具有相同内容相关的任何其他文件。
我在Framework中这样做的方式就是这样
@foreach (AuthenticationDescription p in loginProviders)
{
switch (@p.AuthenticationType)
{
case "Facebook":
<button type="submit" class="btn btn-default facebookButton" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Log in using your @p.Caption account">@p.AuthenticationType</button>
break;
.
.
..and so for other types..
}
}
编辑
@Chris Pratt给出了一个很好的解决方案:here
在Scaffolded items列表的Login.cshtml中,我进行了以下更改:
@foreach (var provider in Model.ExternalLogins)
{
switch (@provider.DisplayName)
{
case "Facebook":
<button type="submit" class="btn btn-default facebookButton" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
break;
}
}
身份现在带有默认UI。它是一个由Razor页面和嵌入式静态文件组成的Razor类库,通过调用AddDefaultIdentity
(内部调用AddDefaultUI
)包含它。因此,项目中实际上不存在任何内容,即使所有内容都像直接在项目中一样运行。
如果你想自定义这个UI,你可以关闭它(通过使用AddIdentity
代替)并构建你喜欢的任何东西,或者(更有可能)你想要在你想要自定义的Razor页面中简单地搭建。项目中的任何实际内容都将有效地覆盖来自默认UI的任何内容。
在Solution Explorer中右键单击您的项目,然后选择Add> New Scaffolded Item。身份标签有一个标签,有一个脚手架。当您选择此选项时,您将看到可以搭建的各种Razor页面的列表。选择一个或多个您想要自定义的(或者只是包含所有内容,如果您愿意)。
对于这个特定的更改,您将在Login.cshtml
中找到代码。