剃刀 – 在身份3中创建声明身份
发布时间:2020-12-16 04:34:46 所属栏目:asp.Net 来源:网络整理
导读:Visual Studio 2015脚手架使用UserManager TUser不能用于创建ClaimsIdentity.有没有人有一个如何做到这一点的工作示例? VS2015脚手架抛出错误: public async TaskClaimsIdentity GenerateUserIdentityAsync(UserManagerApplicationUser manager){ // Note
Visual Studio 2015脚手架使用UserManager< TUser>不能用于创建ClaimsIdentity.有没有人有一个如何做到这一点的工作示例?
VS2015脚手架抛出错误: public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) { // Note the authenticationType must match the one // defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this,DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here return userIdentity; } N.B.:我已经向ApplicationUser添加了与IdentyUser不冲突的属性. 解决方法
UserManager在MVC6版本中已更改.您需要修改代码……
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) { var authenticationType = "Put authentication type Here"; var userIdentity = new ClaimsIdentity(await manager.GetClaimsAsync(this),authenticationType); // Add custom user claims here return userIdentity; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 如何从异常中获取更多细节?
- asp.net-mvc-3 – 带有EF 4.1和EntityState.Modified的MVC3
- asp.net-mvc-4 – 覆盖用于MVC4应用程序的User.IsInRole和[
- 备忘录——IIS程序修改不生效Temporary ASP.NET
- 为什么每个人都在ASP.NET Webforms中依赖注入是困难的,当Pa
- asp.net-mvc – 提供DDD,但需要一些其优点
- asp.net-core – 加密ASP.Net Core中的连接字符串和其他配置
- asp.net – 如何为外部依赖项使用依赖注入?
- asp.net – 保持负载均衡器在长时间运行期间超时
- Asp.Net MVC自定义控件 – 容器
推荐文章
站长推荐
- 全局导入/使用.NET中的别名
- asp.net-mvc – 使URL特定于(通过路由)
- asp.net – 我们如何在共享工作环境中使用版本控
- ASP.Net会员登录问题
- asp.net – 用于Webapp和桌面/移动应用程序的Ope
- asp.net-web-api – ASP.NET Web API IQueryable
- asp.net – Web.Config文件中的多行文本
- asp.net – 如何使用AspNetSqlMembershipProvide
- asp.net-mvc – 准备我的ASP.NET/MVC网站使用SSL
- asp.net-mvc – [HttpPost] public ActionResult
热点阅读