简体   繁体   English

ASP.NET创建用户并记住我

[英]ASP.NET create user and remember me

Using a CreateUserWizard (with only one step) and a logincontrol on the same page. 在同一页面上使用CreateUserWizard(仅一步)和一个logincontrol。

But when i create a new user the Remeber me functionality dosent work (only if i log out and then log in again). 但是,当我创建一个新用户时,请记住我的功能(仅当我注销然后再次登录时)。 I dont know if the persistant cookie is created. 我不知道是否创建持久性cookie。

Im using this code behind: 我在后面使用此代码:

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
    // Sets username into email
    CreateUserWizard cuw = (CreateUserWizard)sender;
    cuw.Email = cuw.UserName;

    // Saves profile data        
    ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);
    p.city = "";
    p.displayName = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("displayName")).Text;
    p.Save();


    FormsAuthentication.SetAuthCookie(cuw.UserName, true);

}

Is this suposed to work? 这应该工作吗? Cheers! 干杯! Johan 约翰

Make sure LoginCreatedUser="False" is set on your control, remove the login control , then instead of 确保在控件上设置了LoginCreatedUser="False" ,然后删除登录控件 ,而不是

FormsAuthentication.SetAuthCookie(cuw.UserName, true);

call 呼叫

FormsAuthentication.RedirectFromLoginPage( cuw.UserName, true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM