解决方案 »

  1.   

    是否将身份信息写到了static类型的变量里?
    .net应用中慎用static,应该放到session或cookies里
      

  2.   


    哦,asp.net 中 form 认证用的就是 cookie,用的是下面代码简历的
          string json = userInfo.ToJsonSerialize();
          FormsAuthenticationTicket authTicket = new
            FormsAuthenticationTicket(1,// version
            userInfo.UserName, // user name
            DateTime.Now,               // creation
            DateTime.Now.AddMinutes(120),// Expiration
            false,                       // Persistent
            json,                        // User data
            "/");                        // cookie path      
          FormsAuthentication.SetAuthCookie(userInfo.UserName, false);
          // Encrypt the ticket.
          string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
          // set cookie domain
          HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
          authCookie.Domain = Globals.RootDomain;
          // Create the cookie.
          HttpContext.Current.Response.Cookies.Add(authCookie);
      

  3.   

    获得用户信息的代码是//取得身份验证票
    FormsAuthenticationTicket ticket = identity.Ticket;
    LoginInfoModel userinfo = ticket.UserData....;
      

  4.   

    全局的static变量,要少用。