asp.net-identity

ASP.NET Identity: Authorize attribute with roles doesn't work on Azure

霸气de小男生 提交于 2019-12-22 06:02:12
问题 I just published my new ASP.NET MVC web site with Identity and OWIN authorization on Azure. Front-end works great, but got a problem with back-end. I use [Authorize] attribute with my admin controllers to check if user has a required role to access it, like this: [Authorize(Roles = "Admin")] On localhost even when using remote Azure SQL database it works fine. But on Azure, any controller with authorize attribute with roles loading several minutes and then throws: A network-related or

Web Api 2 with OWIN OAuth Bearer tokens

眉间皱痕 提交于 2019-12-22 05:52:10
问题 I'm in the process of building a web api in visual studio 2013 and want to authenticate using OWIN middleware and bearer tokens. However I already have a database and don't want to use Microsoft's new Identity framework as the majority of tables and columns that it auto generates I simply don't need. Can anyone point me in the right direction of how to apply this type of authentication without having to use the Microsoft Identity framework? 回答1: My suggestion would be to use the framework but

ASP.NET Identity doesn't update Identity information on same request

风流意气都作罢 提交于 2019-12-22 05:32:06
问题 I am working on a single page application using AngularJS and ASP.NET Identity 2. I log the user in and the cookie is set; however, when I check the Identity of the user on the same request, it shows it as blank and IsAuthenticated is false. However, these are populated on subsequent requests. I was hoping to send back to the UI whether or not the user was logged in on the same request. Is this possible? Code as requested (AngularJS makes AJAX post into WebAPI controller Login method)

How do I inject Identity classes with Ninject?

落爺英雄遲暮 提交于 2019-12-22 04:51:20
问题 I'm trying to use UserManager in a class, but I'm getting this error: Error activating IUserStore{ApplicationUser} No matching bindings are available, and the type is not self-bindable. I'm using the default Startup.cs, which sets a single instance per request: app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); I'm able to get the ApplicationDbContext instance, which I believe is getting injected by Owin (Is

Store does not implement IUserRoleStore<TUser> ASP.NET Core 2.1 Identity

空扰寡人 提交于 2019-12-22 04:06:09
问题 I'm using ASP.NET Core 2.1 Identity. I've overridden IdentityUser because I need to add some additional properties on the user. In Startup.cs services.AddDefaultIdentity<PortalUser>().AddEntityFrameworkStores<ApplicationDbContext>(); ApplicationDbContext.cs public partial class ApplicationDbContext : IdentityDbContext<PortalUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } } PortalUser class public class PortalUser : IdentityUser {

Store does not implement IUserRoleStore<TUser> ASP.NET Core 2.1 Identity

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 04:05:23
问题 I'm using ASP.NET Core 2.1 Identity. I've overridden IdentityUser because I need to add some additional properties on the user. In Startup.cs services.AddDefaultIdentity<PortalUser>().AddEntityFrameworkStores<ApplicationDbContext>(); ApplicationDbContext.cs public partial class ApplicationDbContext : IdentityDbContext<PortalUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } } PortalUser class public class PortalUser : IdentityUser {

Trying to get all roles in Identity

筅森魡賤 提交于 2019-12-22 04:01:30
问题 I am trying to get a list of all the roles in my application. I have looked at the following post Getting All Users... and other sources. Here is my code which I think is what I am supposed to do. var roleStore = new RoleStore<IdentityRole>(context) var roleMngr = new RoleManager<IdentityRole>(roleStore); List<string> roles = roleMngr.Roles.ToList(); However, I’m getting the following error: Cannot implicitly convert type GenericList(IdentityRole) to List(string) . Any suggestions? I am

Invalid Token. while verifying email verification code using UserManager.ConfirmEmailAsync(user.Id, code)

混江龙づ霸主 提交于 2019-12-22 02:35:26
问题 I have recently migrated Asp.net identity 1.0 to 2.0 . I am trying to verify email verification code using below method. But i am getting "Invalid Token" error message. public async Task<HttpResponseMessage> ConfirmEmail(string userName, string code) { ApplicationUser user = UserManager.FindByName(userName); var result = await UserManager.ConfirmEmailAsync(user.Id, code); return Request.CreateResponse(HttpStatusCode.OK, result); } Generating Email verification token using below code (And if i

Invalid Token. while verifying email verification code using UserManager.ConfirmEmailAsync(user.Id, code)

被刻印的时光 ゝ 提交于 2019-12-22 02:35:10
问题 I have recently migrated Asp.net identity 1.0 to 2.0 . I am trying to verify email verification code using below method. But i am getting "Invalid Token" error message. public async Task<HttpResponseMessage> ConfirmEmail(string userName, string code) { ApplicationUser user = UserManager.FindByName(userName); var result = await UserManager.ConfirmEmailAsync(user.Id, code); return Request.CreateResponse(HttpStatusCode.OK, result); } Generating Email verification token using below code (And if i

ASP.Net Identity customizing UserProfile

别等时光非礼了梦想. 提交于 2019-12-22 01:15:48
问题 I'm writing an MVC5 app with EF. I added ASP.NET Identity to the project which created ASPNETUser Tables in my DB the first time I registered a user. However now, when I try to customize UserProfile (as listed in this post: http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on) I get the following: The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations