createuser

Using ASP .NET Membership and Profile with MVC, how can I create a user and set it to HttpContext.Current.User?

不想你离开。 提交于 2019-11-28 16:34:55
I implemented a custom Profile object in code as described by Joel here: How to assign Profile values? I can't get it to work when I'm creating a new user, however. When I do this: Membership.CreateUser(userName, password); Roles.AddUserToRole(userName, "MyRole"); the user is created and added to a role in the database, but HttpContext.Current.User is still empty, and Membership.GetUser() returns null, so this (from Joel's code) doesn't work: static public AccountProfile CurrentUser { get { return (AccountProfile) (ProfileBase.Create(Membership.GetUser().UserName)); } } AccountProfile

Using ASP .NET Membership and Profile with MVC, how can I create a user and set it to HttpContext.Current.User?

a 夏天 提交于 2019-11-27 09:47:56
问题 I implemented a custom Profile object in code as described by Joel here: How to assign Profile values? I can't get it to work when I'm creating a new user, however. When I do this: Membership.CreateUser(userName, password); Roles.AddUserToRole(userName, "MyRole"); the user is created and added to a role in the database, but HttpContext.Current.User is still empty, and Membership.GetUser() returns null, so this (from Joel's code) doesn't work: static public AccountProfile CurrentUser { get {