asp.net-identity-3

ASP.NET 5 Identity 3 users get signed out after some time

徘徊边缘 提交于 2019-12-02 00:02:52
I'm, using RC1 bits and external (Google) authentication, no Identity.EntityFramework. During login, I set 'Remember me' flag. Logged-in user survives browser restart (I see cookie set to expire in 14 days) and website restart. But after some time of inactivity (about 15 min), no matter browser/site were restarted or not, refreshing page lead to signing out, logs says: info: Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware: AuthenticationScheme: Microsoft.AspNet.Identity.Application signed out. AuthenticationScheme: Microsoft.AspNet.Identity.External signed out.

ASP.NET Core Identity: No service for role manager

情到浓时终转凉″ 提交于 2019-11-30 22:39:35
问题 I have an ASP.NET Core app that uses Identity. It works, but when I am trying to add custom roles to the database I run into problems. In Startup ConfigureServices I have added Identity and the role manager as a scoped service like this: services.AddIdentity<Entities.DB.User, IdentityRole<int>>() .AddEntityFrameworkStores<MyDBContext, int>(); services.AddScoped<RoleManager<IdentityRole>>(); and in Startup Configure I inject RoleManager and pass it to my custom class RolesData : public void

Asp.Net core MVC6 How to initially add roles in Identity 3

感情迁移 提交于 2019-11-30 14:32:22
I've looked for this in Stackoverflow and so far it appears there are plenty of questions on adding roles in Identity 1 & 2 but its different in Identity 3. I want to seed roles in the database. I have just two. I intended to use _roleManager which I have injected into the class. Thats fine. My problem is.. there doesnt appear to be any method to actually add a role.. Using CreateAsync is for adding the user to the role.. how do you code to add a role using "_userManager" or do you have to do it another way? EDIT Identity In Identity RoleManager is for creating roles and UserManager is for

How to use ASP.NET Identity 3.0 without Entity Framework [closed]

梦想与她 提交于 2019-11-30 13:41:22
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . All examples I've seen by now for ASP.NET Identity 3.0 use Entity Framework to store user-related data. Are there any example which does not use Entity Framework and where ApplicationUser class is not derived from Microsoft.AspNet.Identity.EntityFramework.IdentityUser ? In ASP.NET Identity 2.x it was needed to

'No database provider has been configured for this DbContext' on SignInManager.PasswordSignInAsync

断了今生、忘了曾经 提交于 2019-11-30 10:43:44
.Net Core 1.0.0 - SDK Preview 2 (x64) .Net Core 1.0.0 - VS "15" Preview 2 (x64) .Net Core 1.0.0 - Runtime (x64) So, we updated an RC1 app to the latest versions above. After many hours of switching references, it's running. However, when logging in (AccountController/Login), I am getting an error at: public class AccountController : BaseController { public UserManager<ApplicationUser> UserManager { get; private set; } public SignInManager<ApplicationUser> SignInManager { get; private set; } private readonly IEmailSender EmailSender; public AccountController(UserManager<ApplicationUser>

How to use ASP.NET Identity 3.0 without Entity Framework [closed]

◇◆丶佛笑我妖孽 提交于 2019-11-30 08:07:58
All examples I've seen by now for ASP.NET Identity 3.0 use Entity Framework to store user-related data. Are there any example which does not use Entity Framework and where ApplicationUser class is not derived from Microsoft.AspNet.Identity.EntityFramework.IdentityUser ? In ASP.NET Identity 2.x it was needed to implement IUser interface. It seems there is not such interface now - so we're not sure how to define User class correctly. There is almost no documentation on this subject. Second problem is with AddIdentity call in Startup.ConfigureServices . It's pretty tied to the particular classes

Asp.Net core MVC6 How to initially add roles in Identity 3

江枫思渺然 提交于 2019-11-29 20:49:08
问题 I've looked for this in Stackoverflow and so far it appears there are plenty of questions on adding roles in Identity 1 & 2 but its different in Identity 3. I want to seed roles in the database. I have just two. I intended to use _roleManager which I have injected into the class. Thats fine. My problem is.. there doesnt appear to be any method to actually add a role.. Using CreateAsync is for adding the user to the role.. how do you code to add a role using "_userManager" or do you have to do

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

一曲冷凌霜 提交于 2019-11-29 11:01:48
The method used in asp.net identity 2 to alter the identity table names does not work in asp.net identity 3. 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 IdentityUser class builder.Entity<IdentityUserLogin<string>>().ToTable("UserLogins"); builder.Entity

ASP.NET Core error: Invalid token Error when implementing Forgot Password

大憨熊 提交于 2019-11-28 09:13:29
问题 In my ASP.NET MVC Core 1.1.1 app with Individual User Accounts mode in VS2017 ver 15.3.3 , I'm implementing Forgot Password functionality. The app is correctly sending the email with a generated link. I can open my email and can see the link generated as follows. Link correctly displays the ResetPassWord.cshtml view. But when I enter required user name, password, confirm password info and click on Submit button, I get the Invalid Token error. Question : How to resolve the issue? NOTE : A. The

Why does this violate the type constraint?

徘徊边缘 提交于 2019-11-27 21:58:17
I'm trying to customise ASP.NET Identity 3 so that it uses integer keys: public class ApplicationUserLogin : IdentityUserLogin<int> { } public class ApplicationUserRole : IdentityUserRole<int> { } public class ApplicationUserClaim : IdentityUserClaim<int> { } public sealed class ApplicationRole : IdentityRole<int> { public ApplicationRole() { } public ApplicationRole(string name) { Name = name; } } public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, ApplicationDbContext, int> { public ApplicationUserStore(ApplicationDbContext context) : base(context) { } } public