ASP.NET Identity外部认证提供程序自定义图标
发布时间:2020-12-16 07:24:53 所属栏目:asp.Net 来源:网络整理
导读:使用SimpleMembership,您可以向外部身份验证提供程序按钮添加一个图标,如下所示: SimpleMembership: Dictionarystring,object FacebooksocialData = new Dictionarystring,object();FacebooksocialData.Add("Icon","/content/images/gui/loginFacebook.png
使用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 Identity(控制器和视图)实现相同的功能? 解决方法
另一种方式:
拿了一些博客中的内容(使用zocial图标,但我发现那些是过度的 – 请参阅css文件,你会明白我的意思): 这样做是这样的: 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> 在上面的其他解决方案/答案中使用类而不是不那么优雅的样式属性. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc-3 – .Doc文件未包含在ASP.NET发布中
- asp.net – 在SignalR 2.0中使用现有的IoC容器
- asp.net – 将DetailsView行组合在一起?
- ASP.NET用户名更改
- asp.net-web-api – ApiController的异步方法 – 什么是利润
- asp.net-mvc – ASP .NET MVC在视图之间存储大量参数
- 用 C# 写一个 Redis 数据同步小工具
- asp.net-web-api2 – 何时将刷新令牌传递给API
- .net – 为每个操作设置MaxAllowedContentLength / maxRequ
- Visual Studio 2017 ASP.NET Core开发
推荐文章
站长推荐
- MVC中TempData、ViewData和ViewBag的区别
- asp.net-mvc-3 – 如何在MVC3中限制FileUpload中
- asp.net – 当我禁用提交按钮以防止双击时,为什么
- asp.net – 浏览器缓存(.js文件)存在多长时间
- 使用System.Net.Mail中的SMTP发送邮件(带附件)
- asp.net – 在什么情况下,.NET进程和AppDomains在
- asp.net – Ajax Control Toolkit正在加载太多脚
- asp.net-mvc – 视图中的条件语句是坏消息吗?
- 反射及LINQ结果集转换dataTable并序列化 将Da
- .net – 在视图中将枚举转换为int
热点阅读