public ActionResult Home() { ViewBag.Result = Session["username"]; SqlConnection con = new SqlConnection("Data Source=WSLK1GF-001;Initial Catalog=ASPState;Integrated Security=True"); con.Open(); string val = Session.SessionID; string query="select SessionItemShort from ASPStateTempSessions where SessionId LIKE '"+Session.SessionID+"%'"; SqlCommand cmd=new SqlCommand(query,con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); byte[] b1 = new byte[0]; //slot to hold raw data in ms/sql varbinary format byte[] b2 = new byte[0]; b1 = (byte[])dr["SessionItemShort"]; string s = Server.UrlEncode(Encoding.ASCII.GetString(b1)); b2 = Encoding.ASCII.GetBytes(s); MemoryStream ms = new MemoryStream(b2); BinaryFormatter bf = new BinaryFormatter(); ms.Write(b2, 0, b2.Length); ms.Seek(0, SeekOrigin.Begin); LoginSession ls = null; object obj=null; try { obj = (LoginSession)bf.Deserialize(ms); } catch(Exception ea) { Response.Write(ea); ms.Close(); } ViewBag.Ses = obj; return View(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)