使用SimpleMembership,您可以将图标添加到外部身份验证提供程序按钮,如下所示:
SimpleMembership:
Dictionary<string, object> FacebooksocialData = new Dictionary<string, object>();
FacebooksocialData.Add("Icon", "/content/images/gui/loginFacebook.png");
OAuthWebSecurity.RegisterFacebookClient(
appId: "x",
appSecret: "x",
displayName: "Facebook",
extraData: FacebooksocialData);
然后在您的视图中将其显示为:
@foreach (AuthenticationClientData p in Model)
{
<button class="externalLoginService" style="cursor:pointer;color:transparent;border:none;background:url(@p.ExtraData["Icon"]);width:94px;height:93px;margin-right:20px;" type="submit" name="provider" value="@p.AuthenticationClient.ProviderName" title="Log in with @p.DisplayName">@p.DisplayName</button>
}
ASP.NET身份(?):
app.UseFacebookAuthentication(
appId: "x",
appSecret: "x");
如何使用ASP.NET标识(控制器和视图)实现同一目的?
另一种方法是:
掌握了此博客中的某些内容(使用了社交图标,但我发现这些图标有些过时了-看到css文件,您就会明白我的意思了):http : //www.beabigrockstar.com/pretty-social-login-buttons -for-asp-net-mvc-5 /
这样做是这样的:
Startup.Auth.cs
(没有多余的内容,只是MVC 5应用中的标准默认内容)
app.UseFacebookAuthentication(appId: "x", appSecret: "x");
app.UseGoogleAuthentication();
CSS:
.socialLoginButton {
cursor:pointer;color:transparent;border:none;width:94px;height:93px;margin-right:20px;
}
.socialLoginButton.facebook {
background:url(/content/images/gui/loginFacebook.png);
}
.socialLoginButton.google {
background:url(/content/images/gui/loginGoogle.png);
}
视图:
<button type="submit" class="externalLoginService socialLoginButton @p.AuthenticationType.ToLower()" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Log in with @p.Caption">@p.AuthenticationType</button>
在上面的其他解决方案/答案中,使用类代替不太优雅的style属性。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句