membership

Change username in MVC 5

淺唱寂寞╮ 提交于 2019-12-20 20:41:58
问题 I am using ASP.NET MVC5 and Identity 2.0 (beta). It is possible for users to change the username? I am trying using UserManager.UpdateAsync method throws an exception. Regrads, Fran. 回答1: Yes it is possible using the UpdateAsync method but you need to ensure that you update both the email and username fields. var user = userManager.FindById(userId); user.Email = email; user.UserName = email; var updateResult = await userManager.UpdateAsync(user); This method works successfully for me 回答2:

What are the pros and cons using the asp.net membership?

坚强是说给别人听的谎言 提交于 2019-12-20 10:33:34
问题 I'm building a new website and a friend suggest to me to use the asp.net membership for the authentication process (login, registration, password recovery, etc..). I saw that everything is stored in an XML file. I would like to know what are the pros and cons using the membership instead of to build something from scratch. 回答1: The MS login solution consists of several parts. Authentication - "Who can access your site" Forms Authentication - This basically creates a secure cookie that says "I

MVC 4 simple membership. How to check is somebody logged in or not

☆樱花仙子☆ 提交于 2019-12-20 03:17:41
问题 I'm new in mvc 4 and can't understand exactly how simple membership worked. After all configuration I put this code to AccountController to see how it works and is it work at all string UserName1 = WebSecurity.CurrentUserName; bool LoginResult= WebSecurity.Login("admin", "111111"); string UserName2 = WebSecurity.CurrentUserName; WebSecurity.Logout(); And when I run debugger I see that after all finished UserName1 = "" LoginResult = true UserName2 = "" Everything is ok except UserName2. Why it

how to use Profile.GetProfile() in a library class?

江枫思渺然 提交于 2019-12-20 01:36:26
问题 I cant figure out how to use Profile.GetProfile() method in a library class. I tried using this method in a Page.aspx.cs and it worked perfectly. How can I make a method that works in the page.aspx.cs, work in the class library. 回答1: In ASP.NET, Profile is a hook into the HttpContext.Current.Profile property, which returns a dynamically generated object of type ProfileCommon, derived from System.Web.Profile.ProfileBase. ProfileCommon apparently includes a GetProfile(string username) method,

how to test whether one list is a member of another

孤街浪徒 提交于 2019-12-19 19:48:07
问题 Lets say I have two lists, ((1 2 3)) and (((1 2 3)) ((4 5))) . I want to be able to tell if the first list is a member of the second list. I have tried to use subsetp , but it does not return true for this query. How can I accomplish this? 回答1: As Rainer Joswig mentioned in the comments, you're not checking for subsets, but for members, which you can do using the aptly named member function. Member returns a generalized boolean, i.e., nil for false, and something, not necessarily t , non- nil

“Remember me” with ASP.NET MVC Authentication is not working

醉酒当歌 提交于 2019-12-19 05:13:12
问题 I have a standard ASP.NET MVC (RC Refresh) web project, with the standard ASP.NET Membership provider and the Account controller that is included in the project template. When I check "Remember me" in my Login form, I am still not being remembered by the site. (Firefox remembers my username and password, but what I expected to happen was to be automatically logged on). Do I have to set and check the cookie manually? If so, how should it best be done? 回答1: You need to pass true/false to the

ASP.Net Membership saves changed password as plain text even with Hashed passwordFormat set

半世苍凉 提交于 2019-12-18 18:13:16
问题 I'm using the ASP.Net SqlMembershipProvider to manage my users. Here is my config: <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15"> <providers> <clear /> <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="SiteDatabase" applicationName="WPR" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" enablePasswordRetrieval="false"

ASP.NET Membership: how to set the user as logged in

核能气质少年 提交于 2019-12-18 10:23:21
问题 I am trying to get the Membership Provider to work. So far I have: <asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate"> </asp:Login> calling : protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if(Membership.ValidateUser(Login1.UserName, Login1.Password)) { Response.Redirect("/admin/default.aspx"); // Set the user as logged in? } } If I enter the correct login/password, the ValidateUser function returns true. So my question is: how do I set the

asp.net membership - how to determine programmatically is user is in role

送分小仙女□ 提交于 2019-12-18 05:43:46
问题 What is the code for determining if a user is in a role? I have set up all the users through the ASP.NET Configuration Security tab but now want to put logic around some key areas so only people in certain roles can see and access these areas. 回答1: if (User.IsInRole("rolename")) { // my action } 回答2: Easy~ HttpContext.Current.User.IsInRole("roleName") 回答3: Check out the Roles class, specifically IsUserInRole, GetUsersInRole, AddUserToRole, etc. I use these all the time. 回答4: thanks to "Chris

Implementing Custom MembershipUser

只谈情不闲聊 提交于 2019-12-17 22:24:44
问题 I am going round in circles and need some help in implementing a Custom MembershipUser so that I can add my own custom Properties to the MembershipUser. I have been following the example on this site: How to: Implement a Custom Membership User The problem I am having is in the constructor of CustomMembershipUser, I think. My CustomMembershipUser has these three additional Properties: firstName, middleName, lastName. public class CustomMembershipProvider : MembershipProvider { public override