2010-10-21 41 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);