2011-07-19 76 views

回答

6

假設你有2個文本框和一個事件處理程序(txtEmail,txtPassword和btnSubmit_Click),並且您已經安裝在kentico現場經理適當的角色,你可以使用這樣的事情:

protected void btnSubmit_Click(object sender, EventArgs e) 
    { 
     CMS.SiteProvider.UserInfo ui = CMS.SiteProvider.UserInfoProvider.AuthenticateUser(txtEmail.Text, txtPassword.Text, CMS.CMSHelper.CMSContext.CurrentSite.SiteName); 
     if (ui != null) 
     { 
      System.Web.Security.FormsAuthentication.SetAuthCookie(ui.UserName, true); 
      CMS.CMSHelper.CMSContext.SetCurrentUser(new CMS.CMSHelper.CurrentUserInfo(ui, true)); 
      CMS.SiteProvider.UserInfoProvider.SetPreferredCultures(ui); 
      Response.Redirect("MY_SECURE_PAGE"); 
     } 
     else 
     { 
      litMessage.Text = "Email/Password incorrect"; 
     } 
    } 
相關問題