草庐IT

ApplicationUser

全部标签

c# - 获取 View 中的当前用户的 ASP.NET 标识

我使用ASP.NETIdentity2.0和MVC。我需要在View中记录用户的姓名、姓氏、电子邮件等。怎么才能得到呢?我只能得到@User.Identity,但没有我的用户类的属性。//inmyview,ineedheremyApplicationUserclass@User.Identity.Name//ApplicationUserclasspublicclassApplicationUser:IdentityUser{publicApplicationUser(){this.CreatedDate=DateTime.Now;}publicDateTimeCreatedDate{

c# - 选择 webApi 模板时如何将 ASP.Net 身份添加到 Asp.Net Core?

我创建了一个.NETCore项目,其中选择了WebApi模板,不包括身份验证。我想在其中添加ASP.NET身份以进行基于角色的授权。我怎样才能做到这一点? 最佳答案 编辑:这回答了问题,但总的来说我同意对上述问题的评论-JWT不记名token最适合API,最好在为您的用例决定最佳方法之前了解该选项。原始答案这将为您提供一个具有aspnet核心身份的熊骨webapi,首先创建您的项目(假设您已经创建了一个新文件夹并且您在其中):dotnetnewwebapi添加aspnet核心标识:dotnetaddpackageMicrosoft.

c# - 具有 JWT 身份验证的 RestSharp 不起作用

这是我“学习”如何操作的页面:https://stormpath.com/blog/token-authentication-asp-net-core但对我来说这不起作用(也不适用于Fiddler)我的ApplicationUser模型有这个Controller:[Authorize]//workswhenit'snotset,doesn'tworkwhenit'sset[Route("api/[controller]")]publicclassApplicationUserController:Controller{privateIRepository_applicationUser

c# - 将 Identity 2.0 抽象到领域模型层

我正在尝试在遵循洋葱架构的ASP.NETMVC5解决方案中实现Identity2.0。我的核心中有一个ApplicationUser。namespaceCore.DomainModel{publicclassApplicationUser{...}}在我的数据访问层中,我使用的是EntityFramework6.1,我的上下文源自IdentityDbContext,这就是问题所在。ApplicationUser需要派生自Microsoft.AspNet.Identity.EntityFramework.IdentityUsernamespaceInfrastructure.DAL{pu

c# - 将用户名字和姓氏添加到 ASP.NET Identity 2?

我改为使用新的ASP.NETIdentity2。我实际上使用的是MicrosoftASP.NETIdentitySamples2.0.0-beta2。谁能告诉我在哪里以及如何修改代码,以便它存储用户的名字和姓氏以及用户详细信息。现在这会成为claim的一部分吗?如果是,我该如何添加它?我想我需要在这里添加这个,这是帐户Controller中的注册方法:if(ModelState.IsValid){varuser=newApplicationUser{UserName=model.Email,Email=model.Email};varresult=awaitUserManager.Cr

c# - AspNetUsers' ID 作为单独表中的外键,一对一关系

我上下查看,尝试了所有能够将AspNetUser表的外键存储在单独的Customer表中的各种不同方法。我在ASP.NET和EntityFramework方面还是个新手,但我已经阅读了很多文章和文档。目前我有这个模型publicclassCustomer{[Display(Name="CustomerID")]publicintCustomerID{get;set;}publicstringUserId{get;set;}[ForeignKey("UserId")]publicvirtualApplicationUserApplicationUser{get;set;}}publicc

c# - 我应该如何从 ASP.NET Core View 访问我的 ApplicationUser 属性?

我正在从事ASP.NetvNext/MVC6项目。我正在掌握ASP.NetIdentity。ApplicationUser类显然是我应该添加任何其他用户属性的地方,这适用于EntityFramework,并且我的其他属性按预期存储在数据库中。但是,当我想从我的View中访问当前登录用户的详细信息时,问题就来了。具体来说,我有一个_loginPartial.cshtml,我想在其中检索和显示用户的Gravatar图标,为此我需要电子邮件地址。RazorView基类有一个User属性,它是一个ClaimsPrincipal。我如何从这个User属性返回到我的ApplicationUser,

c# - 我应该如何从 ASP.NET Core View 访问我的 ApplicationUser 属性?

我正在从事ASP.NetvNext/MVC6项目。我正在掌握ASP.NetIdentity。ApplicationUser类显然是我应该添加任何其他用户属性的地方,这适用于EntityFramework,并且我的其他属性按预期存储在数据库中。但是,当我想从我的View中访问当前登录用户的详细信息时,问题就来了。具体来说,我有一个_loginPartial.cshtml,我想在其中检索和显示用户的Gravatar图标,为此我需要电子邮件地址。RazorView基类有一个User属性,它是一个ClaimsPrincipal。我如何从这个User属性返回到我的ApplicationUser,

c# - 身份密码重置 token 无效

我正在编写MVC5并使用Identity2.0。现在我正在尝试重设密码。但我总是收到重置密码token的“无效token”错误。publicclassAccountController:Controller{publicUserManagerUserManager{get;privateset;}publicAccountController():this(newUserManager(newUserStore(newApplicationDbContext()))){}然后我设置了DataProtectorTokenProvider,publicAccountController(U

c# - 身份密码重置 token 无效

我正在编写MVC5并使用Identity2.0。现在我正在尝试重设密码。但我总是收到重置密码token的“无效token”错误。publicclassAccountController:Controller{publicUserManagerUserManager{get;privateset;}publicAccountController():this(newUserManager(newUserStore(newApplicationDbContext()))){}然后我设置了DataProtectorTokenProvider,publicAccountController(U