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