lifz

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

 public bool ProcessLogin(string userId, string password){

   // Use the account business logic layer to login
   Account account = new Account();
   AccountInfo myAccountInfo = account.SignIn(userId, password);

   //If login is successful then store the state in session and redirect
   if (myAccountInfo != null) {
    HttpContext.Current.Session[ACCOUNT_KEY] = myAccountInfo;
    
    // Determine where to redirect the user back too
    // If they came in from the home page, take them to a similar page
    if (FormsAuthentication.GetRedirectUrl(userId, false).EndsWith(URL_DEFAULT)) {

     FormsAuthentication.SetAuthCookie(userId, false);
     HttpContext.Current.Response.Redirect(URL_ACCOUNTSIGNIN, true);

    }else{
     // Take the customer back to where the came from
     FormsAuthentication.SetAuthCookie(userId, false);

     HttpContext.Current.Response.Redirect(FormsAuthentication.GetRedirectUrl(userId, false), true);
    }

    return true;
   
   }else {
    // Login has failed so return false
    return false;
   }
  }

posted on 2005-08-31 14:36  lifz  阅读(1092)  评论(0)    收藏  举报