2010-10-21 57 views
1

在同一页面上使用CreateUserWizard(只有一个步骤)和一个logincontrol。ASP.NET创建用户并记住我

但是,当我创建一个新用户记住我的功能dosent工作(只有当我注销,然后再次登录)。我不知道是否创建了持久性cookie。使用

林这段代码背后:

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); 

} 

这是suposed工作? 干杯! 约翰

回答

0

确保LoginCreatedUser="False"设置在你的控制,删除登录控制,然后代替

FormsAuthentication.SetAuthCookie(cuw.UserName, true); 

呼叫

FormsAuthentication.RedirectFromLoginPage(cuw.UserName, true);