asp.net-identity

No FindAsync() method on IDbSet<T>

江枫思渺然 提交于 2019-12-30 03:44:07
问题 Is there a reason that the FindAsync() method is omitted from the IDbSet<T> interface? Find is part of the interface, it seems odd the async version isn't available. I'm needing to cast to DbSet<T> to access it, which is a bit cumbersome: User user = await ((DbSet<User>)db.Users) .FindAsync("de7d5d4a-9d0f-48ff-9478-d240cd5eb035"); 回答1: If you own the consumer of IDbSet<T> , which I assume that you do because you want to have access to FindAsync() from within the consumer, then a simple

Does ASP.NET Identity 2 support anonymous users?

跟風遠走 提交于 2019-12-30 03:15:09
问题 I want to allow anonymous/not yet registered and registered users to post on my website. Posts (table) - Id (int) - Subject (nvarchar) - Body (nvarchar) - UserId (uniqueidentifier) The project uses the latest MS technologies (ASP.NET MVC 5+, C#...) How should I go about doing that? Is ASP.NET Identity even the right solution? What's the difference between these: ASP.NET Identity SimpleMembership Membership Provider Update I need to be able to differentiate not yet registered users and record

ASP.NET/Identity Error: The entity type ApplicationUser is not part of the model for the current context

送分小仙女□ 提交于 2019-12-30 02:53:29
问题 In Move ASP.NET Identity store to EF Sql database zoidbergi described an issue similar to that which I'm experiencing, but which was not completely answered. I am receiving the error above when attempting to migrate from the inbuilt .mdf database to MySQL. I am using a Database-First methodology and have successfully created the Entity Model from the underlying Mysql database. No matter whether I recreate the asp.net identity datatables the application chokes as soon as user manager is

ASP.NET Identity “Role-based” Claims

落爺英雄遲暮 提交于 2019-12-30 01:47:08
问题 I understand that I can use claims to make statements about a user: var claims = new List<Claim>(); claims.Add(new Claim(ClaimTypes.Name, "Peter")); claims.Add(new Claim(ClaimTypes.Email, "peter@domain.com")); But how should I store "role-based" claims? For example: The user is a super administrator. claims.Add(new Claim("IsSuperAdmin, "true")); The value parameter "true" feels completely redundant. How else can this statement be expressed using claims? 回答1: This is already done for you by

AspNet Core Identity - cookie not getting set in production

╄→гoц情女王★ 提交于 2019-12-29 08:33:12
问题 I have a .NET Core 2 web app and I want to use ASP.NET Identity to authenticate my users. On .NET Core 1.x, my code was working fine. I migrated to .NET Core 2, and authentication works when running locally in Visual Studio. But when I deploy to a live environment, authentication stops working: the authentication cookie isn't being set in production. My Startup.cs code looks like this: public void ConfigureServices(IServiceCollection services) { services.AddIdentity<AppUser, RavenDB

How can I change the table names used by asp.net identity 3 (vnext)?

微笑、不失礼 提交于 2019-12-29 07:48:09
问题 The method used in asp.net identity 2 to alter the identity table names does not work in asp.net identity 3. 回答1: You can do this easily by changing the entity mapping with extension method ToTable("TableName") on OnModelCreating of your DbContext : And you don't need to use .ForSqlServerToTable() , just .ToTable() should work in any database. protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity<User>().ToTable("Users"); // Your custom

Extending ASP.NET Identity Roles: IdentityRole is not part of the model for the current context

只愿长相守 提交于 2019-12-29 04:42:04
问题 I'm trying to use the new ASP.NET Identity in my MVC5 application, specifically I'm trying to integrate ASP.NET Identity into an existing database. I've already read the questions/answers on SO pertaining to DB First and ASP.NET Identity, and having followed all the recommendations I still can't add roles to my database, although I have no problems adding users. Here's my code: var context = new PayrollDBEntities(); var roleManager = new RoleManager<AspNetRole>(new RoleStore<AspNetRole>

Email Confirmation with MVC 5 and Asp.net Identity

↘锁芯ラ 提交于 2019-12-29 03:18:49
问题 I have been searching, but have not found any documentation on how to implement Email confirmation with MVC 5 using the new ASP.net Identity. There does not seem to be any documentation on this topic (that I could find). Has anyone solved this yet? I am very surprised that this is not included by default in the default MVC 5 project. Any guidance is greatly appreciated. Thank You 回答1: I have written a step-by-step article on how to add email confirmation when using ASP.NET Identity. You can

How to set asp.net Identity cookies expires time

笑着哭i 提交于 2019-12-29 03:04:54
问题 I use Asp.Net Identity to control my app's authorization. Now, I need to do this: if the user does not operate in 30 minutes, jump to the login page, when he login does not select "isPersistent" checkbox. And, if he selected "isPersistent" checkbox, set the expiration date of cookie for 14 days. I try to do this by change the Startup.Auth.cs like this: public void ConfigureAuth(IAppBuilder app) { app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType =

Asp.net Identity Expire Session Cookie

放肆的年华 提交于 2019-12-28 15:12:03
问题 We are using MVC 5.2 and the ASP.NET Identity framework for authentication with a form authentication screen (user&password combo) and identity is persisted using a cookie. I have configuration in my startup method for the Identity framework to set the expiration on the authentication cookie to 30 days, this works just fine when the user selects to 'remember me' (IsPersistent = true). When IsPersistent = false (user elects not to select 'Remember me') a Session cookie is created by default.