开发者

ASP.NET create user and remember me

Using a CreateUserWizard (with only one step) and a logincontrol on the same page.

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.

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(Crea开发者_C百科teUserWizard1.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

FormsAuthentication.SetAuthCookie(cuw.UserName, true);

call

FormsAuthentication.RedirectFromLoginPage( cuw.UserName, true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜