簡體   English   中英

ASP.NET創建用戶並記住我

[英]ASP.NET create user and remember me

在同一頁面上使用CreateUserWizard(僅一步)和一個logincontrol。

但是,當我創建一個新用戶時,請記住我的功能(僅當我注銷然后再次登錄時)。 我不知道是否創建持久性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);

}

這應該工作嗎? 干杯! 約翰

確保在控件上設置了LoginCreatedUser="False" ,然后刪除登錄控件 ,而不是

FormsAuthentication.SetAuthCookie(cuw.UserName, true);

呼叫

FormsAuthentication.RedirectFromLoginPage( cuw.UserName, true);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM