Using the session in the C # Web

Source: Internet
Author: User

Setting and getting the session in the Web:

 PublicList<devicesmodel> Getdevicedatalist (stringOrderID) {List<DevicesModel> DMS =NewList<devicesmodel>(); if(session["devicelist"] ==NULL) {Devicesmodel dm1=NewDevicesmodel (); Dm1.id=1; DM1. OrderID="ORD0001"; DM1. DeviceType="DTM"; DM1. Manufacturer="Cete"; DM1. Model="MC-202"; DM1. SerialNumber="A-3042896"; DM1. Status="Order Saved"; Dms.        ADD (DM1); Devicesmodel DM2=NewDevicesmodel (); Dm2.id=2; DM2. DeviceType="DTM"; DM2. Manufacturer="a&d"; DM2. Model="uc-dcc-c"; DM2. SerialNumber="b-1221-0012"; DM2. Status="Order Saved"; Dms.        ADD (DM2); Devicesmodel dm3=NewDevicesmodel (); Dm3.id=3; Dm3. DeviceType="ATG"; Dm3. Manufacturer="a&d"; Dm3. Model="ua-bbl-c"; Dm3. SerialNumber="b-1001-0012"; Dm3. Status="Order Saved"; Dms.        ADD (DM3); Devicesmodel dm4=NewDevicesmodel (); Dm4.id=4; Dm4. OrderID="ORD0002"; Dm4. DeviceType="ATG"; Dm4. Manufacturer="Cete"; Dm4. Model="MC-232"; Dm4. SerialNumber=""; Dm4. Status="Order Saved"; Dms.        ADD (DM4); session["devicelist"] =DMS; }    Else{DMS= (list<devicesmodel>) session["devicelist"]; }    returnDMS;}
View Code

Empty the session:

 Public string clearsession () {    try    {        session.remove ("devicelist  ");         return " OK " ;    }     Catch (Exception ex)    {        return  ex. Message.tostring ();    }}
View Code

Using the session in the C # Web

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.