asp.net-membership

Thread.CurrentPrincipal set in Application_AuthenticationRequest is not set later in the app

浪尽此生 提交于 2019-12-05 07:08:12
In the global.asax file for the Application_AuthenticationRequest I'm setting the Thread.CurrentPrincipal to a custom principal. I also set the HttpContext.Current.User to the same principal. However later in the app when I need to cast the Thread.CurrentPrincipal to our custom type, I get a runtime error saying: Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'OurCustomPrincipal'. How did the Thread.CurrentPrincipal get reset to RolePrincipal, and more to the point how do I keep it at the CustomPrincipal we set in the global.asax Thanks in advance You surely have

Migrating asp.net membership to Windows Azure

为君一笑 提交于 2019-12-05 06:50:10
问题 I am migrating my asp.net mvc-3 project to windows azure. I have to migrate asp.net membership to windows azure. I read this article. From this artical what i understand is the following points to migrate membership : 1) Migrating membership means just changing the data store where user related information is stored. Means in my case i am using SQL server express 2008 as an on-premises data store. And i just have to chnage it to SQL azure data center. 2) I downloaded ASP.NET Universal

Update custom user profile fields with SimpleMembershipProvider?

丶灬走出姿态 提交于 2019-12-05 04:41:14
I added a custom field to the UserProfile table named ClassOfYear and I'm able to get the data into the profile during registration like this: var confirmationToken = WebSecurity.CreateUserAndAccount(model.UserName, model.Password, propertyValues: new { ClassOfYear = model.ClassOfYear }, requireConfirmationToken: true); However, now I want to be able to update the profile when I manage it but I can't seem to find a method to do so. Do I need to simply update the UserProfile table myself? If not, what is the appropriate way of doing this? FYI, I'm using Dapper as my data access layer, just in

How to set profile data for new user

时间秒杀一切 提交于 2019-12-05 04:21:41
问题 I have an MVC3 site and I am writing code to register a user. The code does this: MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); The next thing it does is this: HttpContext.Profile["FirstNAme"] = model.FirstName; HttpContext.Profile["LastName"] = model.LastName; This is where it fails. The error I get is: This property cannot be set for anonymous users. I understand why; it is because there is

Asp.net Membership - Accounts getting locked out

℡╲_俬逩灬. 提交于 2019-12-05 04:14:15
We're using the standard ASP.net membership features that come with asp.net. Certain accounts in our membership database have a "Locked Out" flag set to true - when/how does this happen? After a configurable number of failed logins (maxInvalidPasswordAttempts, default = 5) within a configurable length of time (passwordAttemptWindow, default = 10 minutes), the account will be locked out. see here for membership related configuration properties These 4 guys did a great job of explaining in depth the asp.net membership controls <system.web> ... authentication & authorization settings ...

Redirect user to Mulitple Login Pages using ASP.NET Membership

混江龙づ霸主 提交于 2019-12-05 03:55:21
问题 Redirect user to Login Page dependent on the Folder they are in. I have a web application with the root directory which is used by all users and the admin site. For people that would require the authenticated functionality of the site, they would require to login and be redirected to root/login.aspx. However, when an Admin needs to login to the root/admin/ section of the site, I want them to be redirected to the login form on root/admin/login.aspx <configuration> <appSettings/>

Differences between Page.User.Identity vs Request.LogonUserIdentity

落爺英雄遲暮 提交于 2019-12-05 03:41:55
What are the differences (behind the scenes) between Page.User.Identity and Request.LogonUserIdentity? Not the differences in type, name, etc but the differences in how they're implemented behind the scenes (i.e. one calls windows xxx api and the other calls asp.net xxx api...). It depends on what mechanism you are using to authenticate users, and what settings you have for impersonation. For example, under the VS development server, using Forms authentication, the standard SQL membership provider and the following code: // m_LoggedIn is a Literal control on the page: m_LoggedIn.Text = string

ASP.NET MVC + MySql Membership Provider, user cannot login

对着背影说爱祢 提交于 2019-12-05 01:04:25
问题 I've been playing around with using MySql as the membership provider for asp.net mvc forms authentication. I've got things configured correctly as far as i can tell, and i can create users via both the register action and asp.net web config site. however, when i try to login with one of the users, it does not work. it returns an error as if i had entered a wrong password, or if the account doesn't exist. i have verified in the database that the account does exist. I've followed the

ASP.NET membership HashAlgorithmType defaults to HMACSHA256, so is password hash keyed?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 23:16:20
问题 I have an ASP.NET 4.5 web application that uses a SqlMembershipProvider . During development, someone put passwordFormat="Clear" in the config causing the passwords to be saved in clear text. I want to remove this and enable hashing of passwords, but I want to make sure the hashes are not being generated using a machine-specific, or auto-generated key. According to what I read on all the related Q&A, the passwords are simply hashed using straight SHA256 and are not machine-specific or keyed.

Automatically sign out from Forms Authentication in ASP.NET when browser is closed

吃可爱长大的小学妹 提交于 2019-12-04 21:44:37
Is there a way to force ASP.NET to sign out from it's authentication when the browser is closed or the user types in a new address? If the browser is left open then I need to keep the user authenticated, so a long timeout on the authentication ticket is preferable. Not sure if this is still an issue but this resolved the issue for me. Just add the following to the Page_Load event of your Start Page: protected void Page_Load(object sender, EventArgs e) { if (Request.UrlReferrer == null || string.IsNullOrEmpty(Request.UrlReferrer.AbsolutePath)) { Session.Abandon(); FormsAuthentication.SignOut();