asp.net-identity

ASP.NET Identity: use GeneratePasswordResetToken on Azure website

白昼怎懂夜的黑 提交于 2019-12-06 04:11:00
问题 I have my web application deployed on Microsoft Azure. However when I want to generate a PasswordResetToken with: var token = await _userManager.GeneratePasswordResetTokenAsync(user.Id); I get the following error: System.Security.Cryptography.CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating. How do I get this to

ASP.NET HttpContext is null in 4.6.1 sample project

廉价感情. 提交于 2019-12-06 03:49:28
1) Create new MVC app targeting 4.6.1 (not core, using MSVS 2015 Update 3) 2) In the generated class ApplicationUser.cs add an assertion: public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) { HttpContext httpContext = HttpContext.Current; Debug.Assert(httpContext != null); // assertion fails // ... } 3) Run program in the debugger, login, the assertion fires. This workaround fixes the problem however I was told that HttpContext should be available across async/await as of .NET 4.5. Should I need the workaround? Web.Config: <httpRuntime

Too many OpenID.nonce cookies cause “Bad Request”

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 03:41:19
问题 I have already gone through links here, here and here which are related to issue I am having. I have Silverlight application using IdentiServer3 for authentication and I started having this issue just now when I implemented log out functionality. Note that the issue has nothing to do with Silverlight because login and logout functionality is actually implemented on the server side which is a classic ASP.Net Web form. (.NET 4.5.1) The application never had logout functionality, so user just

AddToRole() returns “User name can only contain letters or digits” only when users email address contains a dash

烈酒焚心 提交于 2019-12-06 03:11:55
I'm using Asp.Net Identity 2.0, configured so that the users' email address is also the username, so in IdentityConfig I have set AllowOnlyAlphanumericUserNames = false in the ApplicationUserManager constructor: public class ApplicationUserManager : UserManager<ApplicationUser> { public ApplicationUserManager(IUserStore<ApplicationUser> store) : base(store) { } public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context) { var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>())); /

ASP.net identity: How to get current IdentityUser (ApplicationUser)? Where is UserManager.FindById?

坚强是说给别人听的谎言 提交于 2019-12-06 02:16:44
问题 I started with the default template for ASP.net in VS2013. I want to get the current user object. This should be possible without directly accessing the database. In the documentation, this looks very easy: http://blogs.msdn.com/b/webdev/archive/2013/10/16/customizing-profile-information-in-asp-net-identity-in-vs-2013-templates.aspx So it should be var currentUser = manager.FindById(User.Identity.GetUserId()); But FindById is missing! Since several hours, I have been trying to use

ASP.NET Identity - Confusion about [Authorize] And RoleManager

ぐ巨炮叔叔 提交于 2019-12-06 02:16:15
I have been following this post on creating a custom "storage provider" for the new ASP.NET Identity system, and so far it has proven very informative; Creating a custom MySQL Identity Provider I am not using MySQL, I am using RavenDB - and yes, I have already looked at the available RavenDB Identity Providers out there - that isn't really my issue. My issue comes with the IUserRoleStore<IdentityUser> and then the IdentityRole , as well as RoleStore . I see them get created - I even see how they access data to see if a user is in a role, etc. But then later, I just see this .. [Authorize(Roles

Setup Simple Injector with ASP.NET Identity 2.2.1

混江龙づ霸主 提交于 2019-12-06 02:00:33
So I've been trying to setup ASP.NET Identity 2.2.1 and I keep hitting roadblocks. For being something that is supposed to be auto-generated by the framework it sure seems complicated to configure. I think I'm almost there but I'm still having issues setting up IoC with Simple Injector. I've been reading through other StackOverflow questions and blogs about these issues. Most of them seem out of date because they deal with ASP.NET Identity 1.0. There's even been enough changes from 2.0 to 2.2.1 I've run into some issues with out of date solutions. Or the solutions deal with other IoC

How to unauthenticate current user ASP.net mvc Identity

冷暖自知 提交于 2019-12-06 01:24:11
When a user goes to my site they get the login page. Once they successfully login they can logoff and a different user can login. However, if the user clicks the back button while logged in it goes to the login page. At this point a new user can no longer login. I receive an anti-forgery token error. I have tried to logoff any user that goes to the login page. I have tried different ways to logoff. I even tried to Session.Abandon(); Account controller: // GET: /Account/Login [AllowAnonymous] public ActionResult Login(string returnUrl) { EnsureLoggedOut(); ViewBag.ReturnUrl = returnUrl; //

How to Add another Propertys to User.Identity From table AspNetUsers in identity 2.2.1

喜欢而已 提交于 2019-12-06 01:08:44
问题 i Add some new property to asp.net identity 2.2.1 (AspNetUsers table) code first public class ApplicationUser : IdentityUser { public string AccessToken { get; set; } public string FullName { get; set; } public string ProfilePicture { get; set; } public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager

ASP.NET MVC Identity Email/Username with Special Characters

佐手、 提交于 2019-12-05 23:13:10
问题 When registering an account through Web API with an email such as "xxx-yyy@gmail.com", Fiddler returns the follow error. Note that email is used for username as well, so both fields are the same . But it works when registering on MVC itself. ExceptionMessage=User Creation Failed - Identity Exception. Errors were: User name xx-yyy@gmail.com is invalid, can only contain letters or digits. User Object var newUser = new ApplicationUser { UserName = user.Email, Email = user.Email }; IdentifyConfig