Permalink
Browse files

More tests with Inspector Updates

  • Loading branch information...
1 parent 5a04bb1 commit e41d76604fa252f4f38e7a13d22bef201eaeaf6e @Sedward Sedward committed Mar 31, 2010
@@ -222,12 +222,26 @@ private byte[] Serialize(SessionStateItemCollection items)
{
MemoryStream ms = new MemoryStream();
BinaryWriter writer = new BinaryWriter(ms);
+ try
+ {
+ if (items != null)
+ items.Serialize(writer);
+ }
+ catch (Exception e)
+ {
+ if (WriteExceptionsToEventLog)
+ {
+ WriteToEventLog(e, "GetSessionStoreItem");
+ throw new ProviderException(e.Message, e.InnerException);
+ }
+ else
+ throw e;
- if (items != null)
- items.Serialize(writer);
-
- writer.Close();
-
+ }
+ finally
+ {
+ writer.Close();
+ }
return ms.ToArray();
}
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Web;
+
+namespace MongoSessionTest
+{
+ [Serializable]
+ public class MockUser
+ {
+
+ public MockUser()
+ {
+ this.UserID = Guid.NewGuid();
+ this.UserName = "Fake User";
+ this.DateCreated = DateTime.Now;
+ }
+
+ public Guid UserID { get; set; }
+ public string UserName { get; set; }
+ public DateTime DateCreated { get; set; }
+
+ }
+}
@@ -0,0 +1,18 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RedirectedPage.aspx.cs" Inherits="MongoSessionTest.RedirectedPage" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head runat="server">
+ <title></title>
+</head>
+<body>
+ <form id="form1" runat="server">
+ <div>
+ <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
+ <br />
+ <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
+ </div>
+ </form>
+</body>
+</html>
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace MongoSessionTest
+{
+ public partial class RedirectedPage : System.Web.UI.Page
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ Label1.Text = (string)Session["S1"];
+ }
+
+ protected void Button1_Click(object sender, EventArgs e)
+ {
+
+ }
+ }
+}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,26 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="MongoSessionTest.Test" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head runat="server">
+ <title></title>
+</head>
+<body>
+ <form id="form1" runat="server">
+ <div>
+ <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
+ <br />
+ <br />
+ <br />
+ <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
+ <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><br />
+ <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label><br />
+ <br />
+ <br />
+ <asp:Button ID="Button2" runat="server" Text="Abandon Session"
+ onclick="Button2_Click" />
+ </div>
+ </form>
+</body>
+</html>
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+
+namespace MongoSessionTest
+{
+ public partial class Test : System.Web.UI.Page
+ {
+
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!Page.IsPostBack)
+ {
+ MockUser user = new MockUser();
+ Session.Add("User", user);
+ }
+ }
+
+ protected void Button1_Click(object sender, EventArgs e)
+ {
+ MockUser user = (MockUser)Session["User"];
+ Label1.Text = user.UserID.ToString();
+ Label2.Text = user.UserName;
+ Label3.Text = user.DateCreated.ToString();
+ }
+
+ protected void Button2_Click(object sender, EventArgs e)
+ {
+ Session.Abandon();
+ }
+ }
+}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit e41d766

Please sign in to comment.