SessionStateStoreData GetItemInternal(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions, bool exclusive) { Trace.WriteLine("SessionStateServerHandler.GetItemInternal"); Trace.WriteLine("\tid == " + id); Trace.WriteLine("\tpath == " + context.Request.FilePath); locked = false; lockAge = TimeSpan.MinValue; lockId = Int32.MinValue; actions = SessionStateActions.None; if (id == null) { return(null); } StateServerItem item = stateServer.GetItem(id, out locked, out lockAge, out lockId, out actions, exclusive); if (item == null) { Trace.WriteLine("\titem is null (locked == " + locked + ", actions == " + actions + ")"); return(null); } if (actions == SessionStateActions.InitializeItem) { Trace.WriteLine("\titem needs initialization"); return(CreateNewStoreData(context, item.Timeout)); } SessionStateItemCollection items = null; HttpStaticObjectsCollection sobjs = null; MemoryStream stream = null; BinaryReader reader = null; try { if (item.CollectionData != null && item.CollectionData.Length > 0) { stream = new MemoryStream(item.CollectionData); reader = new BinaryReader(stream); items = SessionStateItemCollection.Deserialize(reader); } else { items = new SessionStateItemCollection(); } if (item.StaticObjectsData != null && item.StaticObjectsData.Length > 0) { sobjs = HttpStaticObjectsCollection.FromByteArray(item.StaticObjectsData); } else { sobjs = new HttpStaticObjectsCollection(); } } catch (Exception ex) { throw new HttpException("Failed to retrieve session state.", ex); } finally { if (reader != null) { reader.Close(); } } return(new SessionStateStoreData(items, sobjs, item.Timeout)); }
SessionStateStoreData GetItemInternal (HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions, bool exclusive) { locked = false; lockAge = TimeSpan.MinValue; lockId = Int32.MinValue; actions = SessionStateActions.None; if (id == null) return null; StateServerItem item = stateServer.GetItem (id, out locked, out lockAge, out lockId, out actions, exclusive); if (item == null) return null; if (actions == SessionStateActions.InitializeItem) return CreateNewStoreData (context, item.Timeout); SessionStateItemCollection items = null; HttpStaticObjectsCollection sobjs = null; MemoryStream stream = null; BinaryReader reader = null; Stream input = null; #if NET_4_0 GZipStream gzip = null; #endif try { if (item.CollectionData != null && item.CollectionData.Length > 0) { stream = new MemoryStream (item.CollectionData); #if NET_4_0 if (config.CompressionEnabled) input = gzip = new GZipStream (stream, CompressionMode.Decompress, true); else #endif input = stream; reader = new BinaryReader (input); items = SessionStateItemCollection.Deserialize (reader); #if NET_4_0 if (gzip != null) gzip.Close (); #endif reader.Close (); } else items = new SessionStateItemCollection (); if (item.StaticObjectsData != null && item.StaticObjectsData.Length > 0) sobjs = HttpStaticObjectsCollection.FromByteArray (item.StaticObjectsData); else sobjs = new HttpStaticObjectsCollection (); } catch (Exception ex) { throw new HttpException ("Failed to retrieve session state.", ex); } finally { if (stream != null) stream.Dispose (); #if NET_4_0 if (reader != null) reader.Dispose (); if (gzip != null) gzip.Dispose (); #else if (reader != null) ((IDisposable)reader).Dispose (); #endif } return new SessionStateStoreData (items, sobjs, item.Timeout); }