Permalink
Browse files

Major commit with successful tests in ASP.Net project

  • Loading branch information...
1 parent 99aafc2 commit 386471f460c8c7001e6acd71b85c4f2607239785 @Sedward Sedward committed Mar 24, 2010
@@ -150,7 +150,7 @@ public override void SetAndReleaseItemExclusive(HttpContext context, string id,
locked = false;
actionFlags = 0;
- // String to hold serialized SessionStateItemCollection.
+ // byte array to hold serialized SessionStateItemCollection.
byte[] serializedItems = new byte[0];
// Timeout value from the data store.
int timeout = 0;
@@ -196,7 +196,7 @@ public override void SetAndReleaseItemExclusive(HttpContext context, string id,
if (actionFlags == SessionStateActions.InitializeItem)
item = CreateNewStoreData(context, sessionStateSection.Timeout.Minutes);
else
- item = Deserialize(context, serializedItems, timeout);
+ item = Deserialize(context, session.SessionItems.Bytes, session.Timeout);
}
}
@@ -215,8 +215,7 @@ public override void SetAndReleaseItemExclusive(HttpContext context, string id,
//
// Serialize is called by the SetAndReleaseItemExclusive method to
- // convert the SessionStateItemCollection into a Base64 string to
- // be stored in an Access Memo field.
+ // convert the SessionStateItemCollection into a Binary.
//
private byte[] Serialize(SessionStateItemCollection items)
@@ -234,7 +233,7 @@ private byte[] Serialize(SessionStateItemCollection items)
//
// DeSerialize is called by the GetSessionStoreItem method to
- // convert the Base64 string stored in the Access Memo field to a
+ // convert the Binary to a
// SessionStateItemCollection.
//
@@ -49,12 +49,15 @@ public static Session Get(string id, string applicationName)
{
conn.Open();
Document sessionDoc = sessions.FindOne(selector);
- session = new Session(sessionDoc);
-
- if (session == null)
+ if (sessionDoc == null)
+ {
+ session = null;
+ }
+ else
{
- throw new Exception("The session was not found. SessionID: + " + id);
+ session = new Session(sessionDoc);
}
+
}
catch (MongoException ex)
{
@@ -73,7 +76,7 @@ public static void UpdateSession(string id, int timeout, Binary sessionItems, st
{
Document selector = new Document() { { "SessionId", id }, { "ApplicationName", applicationName },{"LockId",lockId} };
- Document session = new Document() { { "$set", new Document() { { "LockDate", DateTime.Now.AddMinutes((double)timeout) },{"Timeout",timeout},{ "SessionItems", sessionItems },{"SessionItemsCount",sessionItemsCount}} } };
+ Document session = new Document() { { "$set", new Document() { { "LockDate", DateTime.Now.AddMinutes((double)timeout) },{"Timeout",timeout},{"Locked",false},{ "SessionItems", sessionItems },{"SessionItemsCount",sessionItemsCount}} } };
conn.Open();
sessions.Update(session, selector, 0, false);
}
@@ -9,7 +9,9 @@
<body>
<form id="form1" runat="server">
<div>
-
+ <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
+ <asp:Button ID="Button1" runat="server" Text="Submit Text"
+ onclick="Button1_Click" />
</div>
</form>
</body>
@@ -11,11 +11,14 @@ public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
- System.Web.SessionState.SessionIDManager manager = new System.Web.SessionState.SessionIDManager();
-
- string sessionID = manager.CreateSessionID(HttpContext.Current);
- Response.Write(sessionID);
+
+ }
+ protected void Button1_Click(object sender, EventArgs e)
+ {
+ string s = TextBox1.Text;
+ Session.Add("S1", s);
+ Response.Redirect("RedirectedPage.aspx");
}
}
}
Oops, something went wrong.
@@ -12,10 +12,28 @@
</sectionGroup>
</sectionGroup>
</sectionGroup>
+ <section name="Mongo" type="MongoDB.Driver.Configuration.MongoConfiguration, MongoDB.Driver" />
</configSections>
+ <Mongo>
+ <connections>
+ <add key="mongoserver" connectionString="Server=localhost:27017"/>
+ </connections>
+ </Mongo>
<appSettings/>
<connectionStrings/>
<system.web>
+ <sessionState
+ cookieless="false"
+ timeout="20"
+ regenerateExpiredSessionId="true"
+ mode="Custom"
+ customProvider="MongoSessionStoreProvider">
+ <providers>
+ <add name="MongoSessionStoreProvider"
+ type="MongoSessionStore.MongoSessionStoreProvider"
+ writeExceptionsToEventLog="false" />
+ </providers>
+ </sessionState>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
@@ -5,7 +5,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>92cac449-77c0-447c-a40b-bed2f72a6e47</ProjectGuid>
+ <ProjectGuid>{5513DA95-6536-4B46-BDCA-AD0F4029B8FF}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MongoStoreInspector</RootNamespace>
@@ -31,7 +31,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="MongoDB.Driver, Version=1.0.3729.17015, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\mongo\mongodb-csharp\MongoDBDriver\bin\Debug\MongoDB.Driver.dll</HintPath>
+ </Reference>
<Reference Include="System" />
+ <Reference Include="System.configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
@@ -45,9 +50,13 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Options.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Oops, something went wrong.

0 comments on commit 386471f

Please sign in to comment.