asp.net-identity

Registering throws 'Inheritance security rules violated while overriding member'

时光毁灭记忆、已成空白 提交于 2019-12-18 07:45:00
问题 For my school project, I'm using the default Account Controller register function that comes with an MVC project: // POST: /Account/Register [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Register(RegisterViewModel model){ if (ModelState.IsValid){ var user = new ApplicationUser(){UserName = model.UserName}; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded){ await SignInAsync(user, isPersistent: false); return

Registering throws 'Inheritance security rules violated while overriding member'

瘦欲@ 提交于 2019-12-18 07:44:57
问题 For my school project, I'm using the default Account Controller register function that comes with an MVC project: // POST: /Account/Register [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Register(RegisterViewModel model){ if (ModelState.IsValid){ var user = new ApplicationUser(){UserName = model.UserName}; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded){ await SignInAsync(user, isPersistent: false); return

Custom entities with asp net identity (one-to-many)

落爺英雄遲暮 提交于 2019-12-18 07:24:13
问题 When I load a user using the User Manager private UserManager<MyUser> GetUserManager() { var userStore = new UserStore<MyUser>(_context); return new UserManager<MyUser>(userStore); } public MyUser GetUser(string username) { return GetUserManager().FindByName(username); } my UserAddress entity is populated, but my AddressType and Country entities in the UserAddress is null. However using this to load a user and all entities are populated. All I do here is access the entities but don't do

Does ASP.NET Identity 2 use machinekey to hash the password?

大兔子大兔子 提交于 2019-12-18 07:10:33
问题 I have created an application in ASP.NET MVC 5. Now I need to deploy the application on the server. Will my existing passwords work in ASP.NET Identity 2 when I deploy? Or do I need to use the same machine key that I have in my client machine? 回答1: You do not need to set the machine key for passwords. The machine key is used for encryption/decryption (ViewState, Session, Cookies, etc.) not for hashing. If you are using multiple instances of the application (think Azure Cloud Service) then you

How can I check if a password reset token is expired?

我的梦境 提交于 2019-12-18 06:19:32
问题 I'm using ASP.NET Identity, and I have the basic Forgot Password/Reset Password functionality in place. When you fill out the form that you forgot your password, it creates a reset token using _userManager.GeneratePasswordResetTokenAsync(user) [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<IActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await _userManager.FindByNameAsync(model.Email); if (user == null || !(await

Variable cookie path with ASP.NET Identity

怎甘沉沦 提交于 2019-12-18 06:00:38
问题 We migrated a multitenant MVC application from ASP.NET Membership Provider to ASP.NET Identity. This is my Startup.Auth.cs (simplified): public partial class Startup { public void ConfigureAuth(IAppBuilder app) { app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes

Variable cookie path with ASP.NET Identity

你。 提交于 2019-12-18 06:00:12
问题 We migrated a multitenant MVC application from ASP.NET Membership Provider to ASP.NET Identity. This is my Startup.Auth.cs (simplified): public partial class Startup { public void ConfigureAuth(IAppBuilder app) { app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes

Unable to access CreateAsync in User Manager

蹲街弑〆低调 提交于 2019-12-18 05:07:08
问题 I'm trying to use the new Asp.Net Identity system. I've searched this in asp.net site and able to find a tutorial here. I've created Register action and appropriate view for it. But Unable to code it further as I'm struck using User Manager in Identity System. To be precise, It's here. var result = await UserManager.CreateAsync(user, register.Password); The UserManager class throws an exception Using the generic type 'Microsoft.AspNet.Identity.UserManager<TUser,TKey>' requires 2 type

Can we personalize Session Timeout for Roles in ASP.NET MVC 5

丶灬走出姿态 提交于 2019-12-18 05:00:33
问题 The idea is to set different values of Session Timeout for different User Roles in ASP.NET MVC 5 and ASP.NET Identity. Is it possible to do? 回答1: Based on their role you could set the timeout, i.e. HttpContext.Current.Session.Timeout = 20; Going by your previous question you want to do this dynamically. You could store and update the times themselves in session and set for each role on OnActionExecuting of a base controller. if (User.IsInRole("Admin")) { filterContext.HttpContext.Session

How to set up the Entity Framework model for Identity Framework to work against an existing database?

十年热恋 提交于 2019-12-18 04:07:10
问题 I am migrating my old website from PHP to C# MVC. I want to use Microsoft's Identity set-up as it looks rather neat. I already have my solution set up using database-first entity framework. I have the required tables (Users, UserRoles, UserLogins, UserClaims) with all of the foreign keys set up. I've looked at a few ways of setting up the IdentityUser , ones that have used MySqlDatabase and code first, but I'm not sure how to implement my IdentityUser when I already have an established