zoukankan      html  css  js  c++  java
  • Create and retrive session

    PersonSession person = new PersonSession(int.Parse(txtPersonId.Text), txtName.Text, int.Parse 

                                      (txtAge.Text),   chkEmailValidated.Checked);
    PersonSession.CreatePersonSession(person);

    ------------------------

    PersonSession person = PersonSession.GetPersonSession();
           if (person == null)

           {
                Response.Redirect("NotLogged.aspx");
           }

           else
                this.Person = person;

    public PersonSession Person { get; private set; }

    ------------------

    public class PersonSession

    {

     const string KEY = "personDetails";
        public int Id
        {
            get; private set;
        }
        public string Name
        {
            get; private set;
        }
        public int Age
        {
            get; private set;
        }
        public bool HasEmailValidated
        {
            get; private set;
        }
     public PersonSession(int id,string name,int age,bool emailValidated)
     {
            this.Id = id;
            this.Name = name;
            this.Age = age;
            this.HasEmailValidated = emailValidated;
     }
        public static PersonSession GetPersonSession()
        {
            return HttpContext.Current.Session[KEY] as PersonSession;
        }
        public static void CreatePersonSession(PersonSession person)
        {
            HttpContext.Current.Session[KEY] = person;
        } 

    }

  • 相关阅读:
    python线程的几种创建方式
    python进程之间的通信——Queue
    python中进程的几种创建方式
    python中的生成器、迭代器、闭包、装饰器
    java中String和StringBuffer的区别
    python中的元类介绍
    宣传片制作技巧
    树莓派创建WiFi热点
    PCB布线要求
    jsoncpp linux平台编译和arm移植
  • 原文地址:https://www.cnblogs.com/greencolor/p/1669524.html
Copyright © 2011-2022 走看看