├── TestApplicationv2_0 ├── Global.asax ├── App_Start │ ├── FilterConfig.cs │ ├── WebApiConfig.cs │ └── RouteConfig.cs ├── Views │ ├── Default │ │ ├── Index.aspx │ │ ├── SessionAbandon.aspx │ │ ├── SetSessionValWaiting.aspx │ │ ├── SerializePersonWithLists.aspx │ │ ├── PrintSessionVal.aspx │ │ ├── SerializePerson.aspx │ │ ├── SetSessionVal.aspx │ │ ├── GetSerializedPerson.aspx │ │ └── GetSerializedPersonWithPets.aspx │ ├── DefaultWithHelpers │ │ ├── Index.aspx │ │ └── GetAndSetSameRequest.aspx │ ├── BsonDocument │ │ └── GetPerson.aspx │ └── Web.config ├── Models │ └── Person.cs ├── WebFormTests │ ├── SetValues.aspx │ ├── GetValues.aspx │ ├── GetValues.aspx.cs │ ├── SetValues.aspx.designer.cs │ ├── SetValues.aspx.cs │ └── GetValues.aspx.designer.cs ├── Controllers │ ├── ReadOnlySessionStateController.cs │ ├── BsonDocumentController.cs │ └── DefaultController.cs ├── Global.asax.cs ├── Web.Debug.config ├── Web.Release.config ├── Properties │ └── AssemblyInfo.cs ├── packages.config └── Web.config ├── MongoSessionStateStore ├── MongoDB.Bson.dll ├── MongoDB.Bson.pdb ├── MongoDB.Driver.dll ├── MongoDB.Driver.pdb ├── Serialization │ ├── UnSerializedItem.cs │ ├── ISerialization.cs │ ├── SerializationProxy.cs │ ├── BsonSerialization.cs │ └── RawSerialization.cs ├── SessionHelpers │ ├── ISessionHelper.cs │ ├── SessionHelper.cs │ └── MongoSessionHelpers.cs ├── packages.config ├── Properties │ └── AssemblyInfo.cs └── MongoSessionStateStore.csproj ├── TestApplication_RAWSerialization ├── Global.asax ├── App_Start │ ├── FilterConfig.cs │ ├── WebApiConfig.cs │ └── RouteConfig.cs ├── Views │ ├── Home │ │ └── Index.aspx │ └── Web.config ├── Models │ └── Person.cs ├── Global.asax.cs ├── packages.config ├── Controllers │ ├── GetWithoutTypeController.cs │ └── HomeController.cs ├── Web.Debug.config ├── Web.Release.config ├── Properties │ └── AssemblyInfo.cs └── Web.config ├── TestApplication_PersonalizedHelpers ├── Global.asax ├── App_Start │ ├── FilterConfig.cs │ ├── WebApiConfig.cs │ ├── RouteConfig.cs │ └── SessionHelperStart.cs ├── Views │ ├── Home │ │ └── Index.aspx │ └── Web.config ├── WebFormGetData.aspx.cs ├── WebFormGetData.aspx ├── WebFormSetData.aspx ├── WebFormSetData.aspx.cs ├── Global.asax.cs ├── WebFormGetData.aspx.designer.cs ├── WebFormSetData.aspx.designer.cs ├── Web.Debug.config ├── Web.Release.config ├── Properties │ └── AssemblyInfo.cs ├── packages.config ├── Controllers │ └── HomeController.cs └── Web.config ├── TestApplication_RAWSerializationWithoutTypeReference ├── Global.asax ├── App_Start │ ├── FilterConfig.cs │ ├── WebApiConfig.cs │ └── RouteConfig.cs ├── Views │ ├── Home │ │ └── Index.aspx │ └── Web.config ├── Global.asax.cs ├── Controllers │ └── HomeController.cs ├── Web.Debug.config ├── Web.Release.config ├── Properties │ └── AssemblyInfo.cs ├── packages.config └── Web.config ├── TestApplication_RAWSerialization.Tests ├── App.config ├── packages.config ├── TestApplication_RAW_Helpers.cs ├── Properties │ └── AssemblyInfo.cs ├── PrimitiveTypes.cs ├── ObjectTypes.cs └── TestApplication_RAWSerialization.Tests.csproj ├── TestApplicationv2_0.Tests ├── App.config ├── BSONDocumentTest.cs ├── WebFormTests.cs ├── Properties │ └── AssemblyInfo.cs ├── packages.config ├── SerializingJsonObjects_v2_0.cs ├── ElectionsTest_v2_0.cs ├── TestHelpers_v2_0.cs └── TestApplicationv2_0.Tests.csproj ├── TestApplication_PersonalizedHelpers.Tests ├── App.config ├── TestApplication_PersonalizedHelpers_Helpers.cs ├── Properties │ └── AssemblyInfo.cs ├── packages.config ├── TestPersonalizedHelper.cs └── TestApplication_PersonalizedHelpers.Tests.csproj ├── packages └── Microsoft.AspNet.WebApi.Core.4.0.30506.0 │ └── content │ └── web.config.transform ├── .gitignore ├── MongoSessionStateStore.sln └── Readme.md /TestApplicationv2_0/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="TestApplicationv2_0.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /MongoSessionStateStore/MongoDB.Bson.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/HEAD/MongoSessionStateStore/MongoDB.Bson.dll -------------------------------------------------------------------------------- /MongoSessionStateStore/MongoDB.Bson.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/HEAD/MongoSessionStateStore/MongoDB.Bson.pdb -------------------------------------------------------------------------------- /MongoSessionStateStore/MongoDB.Driver.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/HEAD/MongoSessionStateStore/MongoDB.Driver.dll -------------------------------------------------------------------------------- /MongoSessionStateStore/MongoDB.Driver.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/HEAD/MongoSessionStateStore/MongoDB.Driver.pdb -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="TestApplication_RAWSerialization.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="TestApplication_PersonalizedHelpers.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="TestApplication_PersonalizedHelpers.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /TestApplicationv2_0/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace TestApplicationv2_0 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Default/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | Index 9 | 10 | 11 |
12 | Hi 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /MongoSessionStateStore/Serialization/UnSerializedItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MongoSessionStateStore.Serialization 8 | { 9 | public class UnSerializedItem 10 | { 11 | public string SerializedString { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/DefaultWithHelpers/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | Index 9 | 10 | 11 |
12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace TestApplication_RAWSerialization 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Default/SessionAbandon.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | SessionAbandon 9 | 10 | 11 |
12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace TestApplication_PersonalizedHelpers 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Default/SetSessionValWaiting.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | SetSessionValWaiting 9 | 10 | 11 |
12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Default/SerializePersonWithLists.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | SerializePersonWithLists 9 | 10 | 11 |
12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace TestApplication_PersonalizedHelpers 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/Views/Home/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | Index 9 | 10 | 11 |
12 | <%=ViewBag.sessionVal %> 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Views/Home/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | Index 9 | 10 | 11 |
12 | <%=ViewBag.sessionVal %> 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Default/PrintSessionVal.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | PrintSessionVal 9 | 10 | 11 |
12 | <%=ViewBag.sessionVal %> 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/DefaultWithHelpers/GetAndSetSameRequest.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | GetAnsSetSameRequest 9 | 10 | 11 |
12 | <%=ViewBag.allOk %> 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/Views/Home/Index.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | Index 9 | 10 | 11 |
12 | <%=ViewBag.sessionVal %> 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Default/SerializePerson.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | SerializePerson 9 | 10 | 11 |
12 | Serialized. 13 | See result 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Models/Person.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace TestApplicationv2_0.Models 7 | { 8 | public class Person 9 | { 10 | public string Name { get; set; } 11 | public string Surname { get; set; } 12 | public string City { get; set; } 13 | } 14 | 15 | public class PersonPetsList : Person 16 | { 17 | public List PetsList { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/BsonDocument/GetPerson.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | GetPerson 9 | 10 | 11 |
12 | 13 | Name: <%=ViewBag.Name %> 14 | Surname: <%=ViewBag.Surname %> 15 | City: <%=ViewBag.City %> 16 | 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/WebFormGetData.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | 8 | namespace TestApplication_PersonalizedHelpers 9 | { 10 | public partial class WebFormGetData : System.Web.UI.Page 11 | { 12 | protected void Page_Load(object sender, EventArgs e) 13 | { 14 | sessionVal.Text = "" + Session.Mongo("PersonalizedHelperForms") + ""; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Models/Person.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace TestApplication_RAWSerialization.Models 7 | { 8 | [Serializable] 9 | public class Person 10 | { 11 | public string Name { get; set; } 12 | public string Surname { get; set; } 13 | public string City { get; set; } 14 | } 15 | 16 | [Serializable] 17 | public class PersonPetsList : Person 18 | { 19 | public List PetsList { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /MongoSessionStateStore/Serialization/ISerialization.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Web; 8 | using System.Web.SessionState; 9 | 10 | namespace MongoSessionStateStore.Serialization 11 | { 12 | internal interface ISerialization 13 | { 14 | BsonArray Serialize(SessionStateStoreData sessionData); 15 | SessionStateStoreData Deserialize(HttpContext context, BsonArray bsonSerializedItems, int timeout); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Default/SetSessionVal.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | SetSessionVal 9 | 10 | 11 |
12 |
13 | 14 | 15 |
16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /TestApplicationv2_0/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web.Http; 5 | 6 | namespace TestApplicationv2_0 7 | { 8 | public static class WebApiConfig 9 | { 10 | public static void Register(HttpConfiguration config) 11 | { 12 | config.Routes.MapHttpRoute( 13 | name: "DefaultApi", 14 | routeTemplate: "api/{controller}/{id}", 15 | defaults: new { id = RouteParameter.Optional } 16 | ); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/WebFormGetData.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebFormGetData.aspx.cs" Inherits="TestApplication_PersonalizedHelpers.WebFormGetData" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 |
15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web.Http; 5 | 6 | namespace TestApplication_RAWSerialization 7 | { 8 | public static class WebApiConfig 9 | { 10 | public static void Register(HttpConfiguration config) 11 | { 12 | config.Routes.MapHttpRoute( 13 | name: "DefaultApi", 14 | routeTemplate: "api/{controller}/{id}", 15 | defaults: new { id = RouteParameter.Optional } 16 | ); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TestApplicationv2_0/WebFormTests/SetValues.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SetValues.aspx.cs" Inherits="TestApplicationv2_0.WebFormTests.SetTwoValues" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 |
15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web.Http; 5 | 6 | namespace TestApplication_PersonalizedHelpers 7 | { 8 | public static class WebApiConfig 9 | { 10 | public static void Register(HttpConfiguration config) 11 | { 12 | config.Routes.MapHttpRoute( 13 | name: "DefaultApi", 14 | routeTemplate: "api/{controller}/{id}", 15 | defaults: new { id = RouteParameter.Optional } 16 | ); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/WebFormSetData.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebFormSetData.aspx.cs" Inherits="TestApplication_PersonalizedHelpers.WebFormSetData" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 | 15 | 16 |
17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web.Http; 5 | 6 | namespace TestApplication_PersonalizedHelpers 7 | { 8 | public static class WebApiConfig 9 | { 10 | public static void Register(HttpConfiguration config) 11 | { 12 | config.Routes.MapHttpRoute( 13 | name: "DefaultApi", 14 | routeTemplate: "api/{controller}/{id}", 15 | defaults: new { id = RouteParameter.Optional } 16 | ); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/WebFormSetData.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | 8 | namespace TestApplication_PersonalizedHelpers 9 | { 10 | public partial class WebFormSetData : System.Web.UI.Page 11 | { 12 | protected void Page_Load(object sender, EventArgs e) 13 | { 14 | Session.Mongo("PersonalizedHelperForms", "Sample string"); 15 | sessionVal.Text = sessionVal.Text = "" + Session.Mongo("PersonalizedHelperForms") + ""; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /MongoSessionStateStore/SessionHelpers/ISessionHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Web; 7 | using System.Web.SessionState; 8 | 9 | namespace MongoSessionStateStore.SessionHelpers 10 | { 11 | public interface ISessionHelper 12 | { 13 | T getObjValue(object sessionObj); 14 | T Mongo(HttpSessionStateBase session, string key); 15 | void Mongo(HttpSessionStateBase session, string key, T newValue); 16 | T Mongo(HttpSessionState session, string key); 17 | void Mongo(HttpSessionState session, string key, T newValue); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /TestApplicationv2_0/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace TestApplicationv2_0 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{newSesVal}", 19 | defaults: new { controller = "Home", action = "Index", newSesVal = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace TestApplication_RAWSerialization 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace TestApplication_PersonalizedHelpers 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /TestApplicationv2_0/Controllers/ReadOnlySessionStateController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.SessionState; 7 | 8 | namespace TestApplicationv2_0.Controllers 9 | { 10 | [SessionState(SessionStateBehavior.ReadOnly)] 11 | public class ReadOnlySessionStateController : Controller 12 | { 13 | public ActionResult ReadLongRunningValueProcess() 14 | { 15 | int retVal = Session.Mongo( 16 | DefaultWithHelpersController.LONG_RUNNING_VALUE); 17 | ViewBag.sessionVal = retVal; 18 | return View("~/Views/Default/PrintSessionVal.aspx"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace TestApplication_PersonalizedHelpers 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Mvc; 7 | using System.Web.Routing; 8 | 9 | namespace TestApplication_RAWSerialization 10 | { 11 | // Note: For instructions on enabling IIS6 or IIS7 classic mode, 12 | // visit http://go.microsoft.com/?LinkId=9394801 13 | public class MvcApplication : System.Web.HttpApplication 14 | { 15 | protected void Application_Start() 16 | { 17 | AreaRegistration.RegisterAllAreas(); 18 | 19 | WebApiConfig.Register(GlobalConfiguration.Configuration); 20 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 21 | RouteConfig.RegisterRoutes(RouteTable.Routes); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /TestApplicationv2_0/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Mvc; 7 | using System.Web.Routing; 8 | 9 | namespace TestApplicationv2_0 10 | { 11 | // Nota: para obtener instrucciones sobre cómo habilitar el modo clásico de IIS6 o IIS7, 12 | // visite http://go.microsoft.com/?LinkId=9394801 13 | public class MvcApplication : System.Web.HttpApplication 14 | { 15 | protected void Application_Start() 16 | { 17 | AreaRegistration.RegisterAllAreas(); 18 | 19 | WebApiConfig.Register(GlobalConfiguration.Configuration); 20 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 21 | RouteConfig.RegisterRoutes(RouteTable.Routes); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /TestApplication_RAWSerialization.Tests/App.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /TestApplicationv2_0.Tests/App.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers.Tests/App.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Mvc; 7 | using System.Web.Routing; 8 | 9 | namespace TestApplication_PersonalizedHelpers 10 | { 11 | // Nota: para obtener instrucciones sobre cómo habilitar el modo clásico de IIS6 o IIS7, 12 | // visite http://go.microsoft.com/?LinkId=9394801 13 | public class MvcApplication : System.Web.HttpApplication 14 | { 15 | protected void Application_Start() 16 | { 17 | AreaRegistration.RegisterAllAreas(); 18 | 19 | WebApiConfig.Register(GlobalConfiguration.Configuration); 20 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 21 | RouteConfig.RegisterRoutes(RouteTable.Routes); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /TestApplicationv2_0/WebFormTests/GetValues.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetValues.aspx.cs" Inherits="TestApplicationv2_0.WebFormTests.GetValues" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Mvc; 7 | using System.Web.Routing; 8 | 9 | namespace TestApplication_PersonalizedHelpers 10 | { 11 | // Nota: para obtener instrucciones sobre cómo habilitar el modo clásico de IIS6 o IIS7, 12 | // visite http://go.microsoft.com/?LinkId=9394801 13 | public class MvcApplication : System.Web.HttpApplication 14 | { 15 | protected void Application_Start() 16 | { 17 | AreaRegistration.RegisterAllAreas(); 18 | 19 | WebApiConfig.Register(GlobalConfiguration.Configuration); 20 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 21 | RouteConfig.RegisterRoutes(RouteTable.Routes); 22 | // Set the personalized helper when application gets started. 23 | SessionHelperStart.InitSessionHelper(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /MongoSessionStateStore/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /TestApplicationv2_0/WebFormTests/GetValues.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | using TestApplicationv2_0.Models; 8 | 9 | namespace TestApplicationv2_0.WebFormTests 10 | { 11 | public partial class GetValues : System.Web.UI.Page 12 | { 13 | protected void Page_Load(object sender, EventArgs e) 14 | { 15 | Result1Literal.Text = Session.Mongo(SetTwoValues.KEY_NAME).ToString(); 16 | Result2Literal.Text = Session.Mongo(SetTwoValues.KEY_NAME2).ToString(); 17 | Person p = Session.Mongo(SetTwoValues.KEY_NAME3); 18 | PersonPetsList p2 = Session.Mongo(SetTwoValues.KEY_NAME4); 19 | Result3Literal.Text = string.Format("Name: {0}, surname: {1}", p.Name, p.Surname); 20 | Result4Literal.Text = string.Format("Name: {0}, surname: {1}, pet 1 {2}, pet 2 {3}", p2.Name, p2.Surname, p2.PetsList[0], p2.PetsList[1]); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /TestApplicationv2_0.Tests/BSONDocumentTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System.Net; 4 | using TestApplication2_0.Tests; 5 | 6 | namespace TestApplicationv2_0.Tests 7 | { 8 | [TestClass] 9 | public class BSONDocumentTest 10 | { 11 | [TestMethod] 12 | public void PritnBSONPerson() 13 | { 14 | CookieContainer cookieContainer = new CookieContainer(); 15 | string url = 16 | TestHelpers_v2_0.DEFAULT_WITH_BSON + 17 | TestHelpers_v2_0.SET_BSON_VAL, 18 | url2 = 19 | TestHelpers_v2_0.DEFAULT_WITH_BSON + 20 | TestHelpers_v2_0.GET_BSON_VAL; 21 | TestHelpers_v2_0.DoRequest(url, cookieContainer); 22 | string result = TestHelpers_v2_0.DoRequest(url2, cookieContainer); 23 | StringAssert.Contains(result, @" 24 | Name: Marc 25 | Surname: Cortada 26 | City: Barcelona 27 | "); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace TestApplication_PersonalizedHelpers.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | public const string KEY_NAME = "value"; 12 | public const string KEY_NAME2 = "value2"; 13 | public const string KEY_NAME3 = "value3"; 14 | public const string VIEW_DATA_VAL = "sessionVal"; 15 | // 16 | // GET: /Home/ 17 | 18 | public ActionResult Index() 19 | { 20 | dynamic personGet = Session[HomeController.KEY_NAME]; 21 | dynamic personPetsListGet = Session[HomeController.KEY_NAME3]; 22 | 23 | if ((personGet is MongoSessionStateStore.Serialization.UnSerializedItem) && 24 | (personPetsListGet is MongoSessionStateStore.Serialization.UnSerializedItem)) 25 | ViewBag.sessionVal = "True"; 26 | else 27 | ViewBag.sessionVal = "False"; 28 | 29 | return View(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization.Tests/TestApplication_RAW_Helpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace TestApplication_RAWSerialization.Tests 10 | { 11 | internal static class TestApplication_RAW_Helpers 12 | { 13 | public static string BASE_URL = "http://localhost/TestApplication_RAWSerialization/{0}/{1}"; 14 | public static string BASE_URL_2 = "http://localhost/TestApplication_RAWSerializationWithoutTypeReference/{0}/{1}"; 15 | public static string CONTROLLER = "Home"; 16 | public static string CONTROLLER2 = "GetWithoutType"; 17 | 18 | public static string DoRequest( 19 | string url, 20 | CookieContainer cookieContainer) 21 | { 22 | HttpWebRequest request = 23 | (HttpWebRequest)WebRequest.Create(url); 24 | request.CookieContainer = cookieContainer; 25 | var stream = request.GetResponse().GetResponseStream(); 26 | StreamReader reader = new StreamReader(stream); 27 | return reader.ReadToEnd(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/Microsoft.AspNet.WebApi.Core.4.0.30506.0/content/web.config.transform: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Controllers/BsonDocumentController.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Mvc; 7 | using TestApplicationv2_0.Models; 8 | 9 | namespace TestApplicationv2_0.Controllers 10 | { 11 | public class BsonDocumentController : Controller 12 | { 13 | // 14 | // GET: /BsonDocument/ 15 | 16 | public ActionResult SetPerson() 17 | { 18 | //var doc = BsonDocument.Create(new Person() { Name = "Marc", Surname = "Cortada", City = "Barcelona" }); 19 | BsonDocument doc = new BsonDocument(); 20 | doc.Add("Name", "Marc"); 21 | doc.Add("Surname", "Cortada"); 22 | doc.Add("City", "Barcelona"); 23 | Session.Mongo("BsonValueKey", doc); 24 | return View("~/Views/DefaultWithHelpers/Index.aspx"); 25 | } 26 | 27 | public ActionResult GetPerson() 28 | { 29 | var doc = Session.Mongo("BsonValueKey"); 30 | ViewBag.Name = doc.GetValue("Name"); 31 | ViewBag.Surname = doc.GetValue("Surname"); 32 | ViewBag.City = doc.GetValue("City"); 33 | return View(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers.Tests/TestApplication_PersonalizedHelpers_Helpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace TestApplication_PersonalizedHelpers.Tests 10 | { 11 | class TestApplication_PersonalizedHelpers_Helpers 12 | { 13 | public static string BASE_URL_MVC = "http://localhost/TestApplication_PersonalizedHelpers/{0}/{1}"; 14 | public static string BASE_URL_FORMS = "http://localhost/TestApplication_PersonalizedHelpers/{0}"; 15 | public static string CONTROLLER = "home"; 16 | public static string WEB_FORM1 = "WebFormGetData.aspx"; 17 | public static string WEB_FORM2 = "WebFormSetData.aspx"; 18 | 19 | public static string DoRequest( 20 | string url, 21 | CookieContainer cookieContainer) 22 | { 23 | HttpWebRequest request = 24 | (HttpWebRequest)WebRequest.Create(url); 25 | request.CookieContainer = cookieContainer; 26 | var stream = request.GetResponse().GetResponseStream(); 27 | StreamReader reader = new StreamReader(stream); 28 | return reader.ReadToEnd(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MongoSessionStateStore/Serialization/SerializationProxy.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Web; 8 | using System.Web.SessionState; 9 | 10 | namespace MongoSessionStateStore.Serialization 11 | { 12 | public class SerializationProxy : ISerialization 13 | { 14 | public enum SerializerType 15 | { 16 | BsonSerialization, 17 | RawSerialization 18 | }; 19 | 20 | private ISerialization _serializer; 21 | 22 | public SerializationProxy(SerializerType serializerType) 23 | { 24 | _serializer = new BsonSerialization(); 25 | if (serializerType == SerializerType.RawSerialization) 26 | _serializer = new RawSerialization(); 27 | } 28 | 29 | public BsonArray Serialize(SessionStateStoreData sessionData) 30 | { 31 | return _serializer.Serialize(sessionData); 32 | } 33 | 34 | public SessionStateStoreData Deserialize( 35 | HttpContext context, 36 | BsonArray bsonSerializedItems, 37 | int timeout) 38 | { 39 | return _serializer.Deserialize(context, bsonSerializedItems, timeout); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /TestApplicationv2_0.Tests/WebFormTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System.Net; 4 | using TestApplication2_0.Tests; 5 | 6 | namespace TestApplicationv2_0.Tests 7 | { 8 | [TestClass] 9 | public class WebFormTests 10 | { 11 | [TestMethod] 12 | public void GetAndSetValues() 13 | { 14 | CookieContainer cookieContainer = new CookieContainer(); 15 | string url = 16 | TestHelpers_v2_0.BASE_URL_FORMS + 17 | TestHelpers_v2_0.SET_VALUE_WEB_FORM, 18 | url2 = 19 | TestHelpers_v2_0.BASE_URL_FORMS + 20 | TestHelpers_v2_0.GET_VALUE_WEB_FORM; 21 | 22 | string result = TestHelpers_v2_0.DoRequest(url, cookieContainer); 23 | StringAssert.Contains(result, "OK"); 24 | 25 | string result2 = TestHelpers_v2_0.DoRequest(url2, cookieContainer); 26 | StringAssert.Contains(result2, @"314"); 27 | StringAssert.Contains(result2, @"3,14"); 28 | StringAssert.Contains(result2, @"Name: Marc, surname: Cortada"); 29 | StringAssert.Contains(result2, @"Name: Marc2, surname: Cortada2, pet 1 cat, pet 2 dog"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Controllers/GetWithoutTypeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace TestApplication_RAWSerialization.Controllers 8 | { 9 | public class GetWithoutTypeController : Controller 10 | { 11 | // 12 | // GET: /GetWithoutType/ 13 | 14 | public ActionResult Index() 15 | { 16 | dynamic personGet = Session[HomeController.KEY_NAME]; 17 | dynamic personPetsListGet = Session[HomeController.KEY_NAME3]; 18 | 19 | // We use literal values because we don't have any reference to the 20 | // real object type 21 | if (("Marc" == personGet.Name) && 22 | ("Cortada" == personGet.Surname) && 23 | ("Barcelona" == personGet.City) && 24 | ("Marc2" == personPetsListGet.Name) && 25 | ("Cortada2" == personPetsListGet.Surname) && 26 | ("cat" == personPetsListGet.PetsList[0]) && 27 | ("dog" == personPetsListGet.PetsList[1])) 28 | ViewBag.sessionVal = "True"; 29 | else 30 | ViewBag.sessionVal = "False"; 31 | 32 | return View("~/Views/Home/Index.aspx"); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Default/GetSerializedPerson.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | GetSerializedPerson 9 | 10 | 11 |
12 | Person 13 | 14 |
15 | <%: Html.DisplayNameFor(model => model.Name) %> 16 |
17 |
18 | <%: Html.DisplayFor(model => model.Name) %> 19 |
20 | 21 |
22 | <%: Html.DisplayNameFor(model => model.Surname) %> 23 |
24 |
25 | <%: Html.DisplayFor(model => model.Surname) %> 26 |
27 | 28 |
29 | <%: Html.DisplayNameFor(model => model.City) %> 30 |
31 |
32 | <%: Html.DisplayFor(model => model.City) %> 33 |
34 |
35 |

36 | <%: Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) %> | 37 | <%: Html.ActionLink("Back to List", "Index") %> 38 |

39 | 40 | 41 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /TestApplicationv2_0/WebFormTests/SetValues.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Este código fue generado por una herramienta. 4 | // 5 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si 6 | // se vuelve a generar el código. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace TestApplicationv2_0.WebFormTests { 11 | 12 | 13 | public partial class SetTwoValues { 14 | 15 | /// 16 | /// Control form1. 17 | /// 18 | /// 19 | /// Campo generado automáticamente. 20 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// Control ResultLiteral. 26 | /// 27 | /// 28 | /// Campo generado automáticamente. 29 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 30 | /// 31 | protected global::System.Web.UI.WebControls.Literal ResultLiteral; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/WebFormGetData.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Este código fue generado por una herramienta. 4 | // 5 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si 6 | // se vuelve a generar el código. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace TestApplication_PersonalizedHelpers { 11 | 12 | 13 | public partial class WebFormGetData { 14 | 15 | /// 16 | /// Control form1. 17 | /// 18 | /// 19 | /// Campo generado automáticamente. 20 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// Control sessionVal. 26 | /// 27 | /// 28 | /// Campo generado automáticamente. 29 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 30 | /// 31 | protected global::System.Web.UI.WebControls.Literal sessionVal; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/WebFormSetData.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Este código fue generado por una herramienta. 4 | // 5 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si 6 | // se vuelve a generar el código. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace TestApplication_PersonalizedHelpers { 11 | 12 | 13 | public partial class WebFormSetData { 14 | 15 | /// 16 | /// Control form1. 17 | /// 18 | /// 19 | /// Campo generado automáticamente. 20 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// Control sessionVal. 26 | /// 27 | /// 28 | /// Campo generado automáticamente. 29 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 30 | /// 31 | protected global::System.Web.UI.WebControls.Literal sessionVal; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestApplication_RAWSerialization")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Enhesa")] 12 | [assembly: AssemblyProduct("TestApplication_RAWSerialization")] 13 | [assembly: AssemblyCopyright("Copyright © Enhesa 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8c1106dc-f9d3-4970-bac7-80fad2c76dbc")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestApplication_RAWSerialization.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Enhesa")] 12 | [assembly: AssemblyProduct("TestApplication_RAWSerialization.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © Enhesa 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("24651b8d-04e8-4470-8f75-598477b4263c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /MongoSessionStateStore/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MongoSessionStateStore")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("MongoSessionStateStore")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("53451529-6eba-4e18-9307-96b5cc6cd2e5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // La información general sobre un ensamblado se controla mediante el siguiente 6 | // conjunto de atributos. Cambie los valores de estos atributos para modificar la información 7 | // asociada con un ensamblado. 8 | [assembly: AssemblyTitle("TestApplicationv2_0")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestApplicationv2_0")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Si ComVisible se establece en False, los componentes COM no verán los 18 | // tipos de este ensamblado. Si necesita obtener acceso a un tipo de este ensamblado desde 19 | // COM, establezca el atributo ComVisible en True en este tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // El siguiente GUID sirve como ID de typelib si este proyecto se expone a COM 23 | [assembly: Guid("a0a5e76f-72bb-420c-ae50-de78f1e57089")] 24 | 25 | // La información de versión de un ensamblado consta de los siguientes cuatro valores: 26 | // 27 | // Versión principal 28 | // Versión secundaria 29 | // Número de compilación 30 | // Revisión 31 | // 32 | // Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión 33 | // mediante el carácter '*', como se muestra a continuación: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /TestApplicationv2_0.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // La información general sobre un ensamblado se controla mediante el siguiente 6 | // conjunto de atributos. Cambie los valores de estos atributos para modificar la información 7 | // asociada con un ensamblado. 8 | [assembly: AssemblyTitle("TestApplicationv2_0.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestApplicationv2_0.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Si ComVisible se establece en False, los componentes COM no verán los 18 | // tipos de este ensamblado. Si necesita obtener acceso a un tipo de este ensamblado desde 19 | // COM, establezca el atributo ComVisible en True en este tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // El siguiente GUID sirve como ID de typelib si este proyecto se expone a COM 23 | [assembly: Guid("5a57c318-822a-4a70-88e9-9d542bc49231")] 24 | 25 | // La información de versión de un ensamblado consta de los siguientes cuatro valores: 26 | // 27 | // Versión principal 28 | // Versión secundaria 29 | // Número de compilación 30 | // Revisión 31 | // 32 | // Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión 33 | // mediante el carácter '*', como se muestra a continuación: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // La información general sobre un ensamblado se controla mediante el siguiente 6 | // conjunto de atributos. Cambie los valores de estos atributos para modificar la información 7 | // asociada con un ensamblado. 8 | [assembly: AssemblyTitle("TestApplication_PersonalizedHelpers")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestApplication_PersonalizedHelpers")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Si ComVisible se establece en False, los componentes COM no verán los 18 | // tipos de este ensamblado. Si necesita obtener acceso a un tipo de este ensamblado desde 19 | // COM, establezca el atributo ComVisible en True en este tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // El siguiente GUID sirve como ID de typelib si este proyecto se expone a COM 23 | [assembly: Guid("ecfa2800-1be3-44b5-8ecc-fb0924f1c113")] 24 | 25 | // La información de versión de un ensamblado consta de los siguientes cuatro valores: 26 | // 27 | // Versión principal 28 | // Versión secundaria 29 | // Número de compilación 30 | // Revisión 31 | // 32 | // Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión 33 | // mediante el carácter '*', como se muestra a continuación: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /TestApplicationv2_0.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // La información general sobre un ensamblado se controla mediante el siguiente 6 | // conjunto de atributos. Cambie los valores de estos atributos para modificar la información 7 | // asociada con un ensamblado. 8 | [assembly: AssemblyTitle("TestApplication_PersonalizedHelpers.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestApplication_PersonalizedHelpers.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Si ComVisible se establece en False, los componentes COM no verán los 18 | // tipos de este ensamblado. Si necesita obtener acceso a un tipo de este ensamblado desde 19 | // COM, establezca el atributo ComVisible en True en este tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // El siguiente GUID sirve como ID de typelib si este proyecto se expone a COM 23 | [assembly: Guid("b2cce33f-7a46-4506-8511-61ebeb75cee7")] 24 | 25 | // La información de versión de un ensamblado consta de los siguientes cuatro valores: 26 | // 27 | // Versión principal 28 | // Versión secundaria 29 | // Número de compilación 30 | // Revisión 31 | // 32 | // Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión 33 | // mediante el carácter '*', como se muestra a continuación: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // La información general sobre un ensamblado se controla mediante el siguiente 6 | // conjunto de atributos. Cambie los valores de estos atributos para modificar la información 7 | // asociada con un ensamblado. 8 | [assembly: AssemblyTitle("TestApplication_RAWSerializationWithoutTypeReference")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestApplication_RAWSerializationWithoutTypeReference")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Si ComVisible se establece en False, los componentes COM no verán los 18 | // tipos de este ensamblado. Si necesita obtener acceso a un tipo de este ensamblado desde 19 | // COM, establezca el atributo ComVisible en True en este tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // El siguiente GUID sirve como ID de typelib si este proyecto se expone a COM 23 | [assembly: Guid("4d2fc4d5-45ff-4262-bce5-a8867949aba7")] 24 | 25 | // La información de versión de un ensamblado consta de los siguientes cuatro valores: 26 | // 27 | // Versión principal 28 | // Versión secundaria 29 | // Número de compilación 30 | // Revisión 31 | // 32 | // Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión 33 | // mediante el carácter '*', como se muestra a continuación: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Default/GetSerializedPersonWithPets.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | GetSerializedPersonWithPets 9 | 10 | 11 |
12 | PersonPetsList 13 | 14 |
15 | <%: Html.DisplayNameFor(model => model.Name) %> 16 |
17 |
18 | <%: Html.DisplayFor(model => model.Name) %> 19 |
20 | 21 |
22 | <%: Html.DisplayNameFor(model => model.Surname) %> 23 |
24 |
25 | <%: Html.DisplayFor(model => model.Surname) %> 26 |
27 | 28 |
29 | <%: Html.DisplayNameFor(model => model.City) %> 30 |
31 |
32 | <%: Html.DisplayFor(model => model.City) %> 33 |
34 |
35 | <%: Html.DisplayFor(model => model.City) %> 36 |
37 | <%foreach (string petName in Model.PetsList) 38 | { 39 | %> 40 |
41 | <%: Html.DisplayFor(model => petName) %> 42 |
43 | <%} %> 44 |
45 |

46 | <%: Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) %> | 47 | <%: Html.ActionLink("Back to List", "Index") %> 48 |

49 | 50 | 51 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /TestApplicationv2_0/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/App_Start/SessionHelperStart.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using MongoSessionStateStore.SessionHelpers; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Web; 7 | 8 | namespace TestApplication_PersonalizedHelpers 9 | { 10 | public static class SessionHelperStart 11 | { 12 | public static void InitSessionHelper() 13 | { 14 | System.Web.Mvc.MongoSessionUserHelpersMvc.SetHelper(new SessionHelperPersonalizedPartial()); 15 | } 16 | } 17 | 18 | // Example of partial personalization of Session Helper 19 | public class SessionHelperPersonalizedPartial : SessionHelper 20 | { 21 | public override T getObjValue(object sessionObj) 22 | { 23 | object obj = "This is a sample class of a partial personalized helper"; 24 | return (T)obj; 25 | } 26 | } 27 | 28 | // Example of full personalization of Session Helper 29 | public class SessionHelperPersonalized : ISessionHelper 30 | { 31 | public T getObjValue(object sessionObj) 32 | { 33 | object obj = "This is a sample class of a full personalized helper"; 34 | return (T)obj; 35 | } 36 | 37 | public T Mongo(HttpSessionStateBase session, string key) 38 | { 39 | var sessionObj = session[key]; 40 | return getObjValue(sessionObj); 41 | } 42 | 43 | public void Mongo(HttpSessionStateBase session, string key, T newValue) 44 | { 45 | session[key] = newValue; 46 | } 47 | 48 | public T Mongo(System.Web.SessionState.HttpSessionState session, string key) 49 | { 50 | var sessionObj = session[key]; 51 | return getObjValue(sessionObj); 52 | } 53 | 54 | public void Mongo(System.Web.SessionState.HttpSessionState session, string key, T newValue) 55 | { 56 | session[key] = newValue; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace TestApplication_PersonalizedHelpers.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | // 12 | // GET: /Home/ 13 | 14 | public ActionResult Index() 15 | { 16 | ViewBag.sessionVal = "OK"; 17 | return View(); 18 | } 19 | 20 | public ActionResult SetTestPersonalizedHelper() 21 | { 22 | Session.Mongo("PersonalizedHelper", "Test string"); 23 | ViewBag.sessionVal = Session.Mongo("PersonalizedHelper"); 24 | return View("~/Views/Home/Index.aspx"); 25 | } 26 | 27 | public ActionResult GetTestPersonalizedHelper() 28 | { 29 | ViewBag.sessionVal = Session.Mongo("PersonalizedHelper"); 30 | return View("~/Views/Home/Index.aspx"); 31 | } 32 | 33 | public ActionResult ChangeHelperToFullPersonalized() 34 | { 35 | //Do NOT set the helper class here. This is only for test purposes. 36 | //Is recommended to do it in an App_Start class and call the method in Application_Start event. 37 | System.Web.Mvc.MongoSessionUserHelpersMvc.SetHelper(new SessionHelperPersonalized()); 38 | ViewBag.sessionVal = "OK"; 39 | return View("~/Views/Home/Index.aspx"); 40 | } 41 | 42 | public ActionResult ChangeHelperToPartialPersonalized() 43 | { 44 | //Do NOT set the helper class here. This is only for test purposes. 45 | //Is recommended to do it in an App_Start class and call the method in Application_Start event. 46 | System.Web.Mvc.MongoSessionUserHelpersMvc.SetHelper(new SessionHelperPersonalizedPartial()); 47 | ViewBag.sessionVal = "OK"; 48 | return View("~/Views/Home/Index.aspx"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /MongoSessionStateStore/Serialization/BsonSerialization.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Web; 8 | using System.Web.SessionState; 9 | 10 | namespace MongoSessionStateStore.Serialization 11 | { 12 | internal class BsonSerialization : ISerialization 13 | { 14 | public BsonArray Serialize(SessionStateStoreData sessionData) 15 | { 16 | BsonArray bsonArraySession = new BsonArray(); 17 | for (int i = 0; i < sessionData.Items.Count; i++) 18 | { 19 | string key = sessionData.Items.Keys[i]; 20 | var sessionObj = sessionData.Items[key]; 21 | if (sessionObj is BsonValue) 22 | { 23 | bsonArraySession.Add(new BsonDocument(key, sessionObj as BsonValue)); 24 | } 25 | else 26 | { 27 | BsonValue singleValue; 28 | 29 | if (BsonTypeMapper.TryMapToBsonValue(sessionObj, out singleValue)) 30 | bsonArraySession.Add(new BsonDocument(key, singleValue)); 31 | else 32 | bsonArraySession.Add(new BsonDocument(key, sessionObj.ToBsonDocument())); 33 | } 34 | } 35 | return bsonArraySession; 36 | } 37 | 38 | public SessionStateStoreData Deserialize( 39 | HttpContext context, 40 | BsonArray bsonSerializedItems, 41 | int timeout) 42 | { 43 | var sessionItems = new SessionStateItemCollection(); 44 | 45 | foreach (var value in bsonSerializedItems.Values) 46 | { 47 | var document = value as BsonDocument; 48 | string name = document.Names.FirstOrDefault(); 49 | sessionItems[name] = document.Values.FirstOrDefault(); 50 | } 51 | 52 | return new SessionStateStoreData(sessionItems, 53 | SessionStateUtility.GetSessionStaticObjects(context), 54 | timeout); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /TestApplicationv2_0/WebFormTests/SetValues.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | using TestApplicationv2_0.Models; 8 | 9 | namespace TestApplicationv2_0.WebFormTests 10 | { 11 | public partial class SetTwoValues : System.Web.UI.Page 12 | { 13 | public const string KEY_NAME = "aspx_value"; 14 | public const string KEY_NAME2 = "aspx_value2"; 15 | public const string KEY_NAME3 = "aspx_value3"; 16 | public const string KEY_NAME4 = "aspx_value4"; 17 | 18 | protected void Page_Load(object sender, EventArgs e) 19 | { 20 | int intValue = 314; 21 | double doubleValue = 3.14d; 22 | Person personValue = new Person() { Name = "Marc", Surname = "Cortada" }; 23 | PersonPetsList personPetsValue = new PersonPetsList() 24 | { 25 | Name = "Marc2", 26 | Surname = "Cortada2", 27 | PetsList = new List() { "cat", "dog" } 28 | }; 29 | 30 | Session.Mongo(KEY_NAME, intValue); 31 | Session.Mongo(KEY_NAME2, doubleValue); 32 | Session.Mongo(KEY_NAME3, personValue); 33 | Session.Mongo(KEY_NAME4, personPetsValue); 34 | 35 | if ((intValue == Session.Mongo(KEY_NAME)) && 36 | (doubleValue == Session.Mongo(KEY_NAME2)) && 37 | (personValue.Name == Session.Mongo(KEY_NAME3).Name) && 38 | (personValue.Surname == Session.Mongo(KEY_NAME3).Surname) && 39 | (personPetsValue.Name == Session.Mongo(KEY_NAME4).Name) && 40 | (personPetsValue.Surname == Session.Mongo(KEY_NAME4).Surname) && 41 | (personPetsValue.PetsList[0] == Session.Mongo(KEY_NAME4).PetsList[0]) && 42 | (personPetsValue.PetsList[1] == Session.Mongo(KEY_NAME4).PetsList[1])) 43 | this.ResultLiteral.Text = "OK"; 44 | else 45 | this.ResultLiteral.Text = "KO"; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /TestApplicationv2_0/WebFormTests/GetValues.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Este código fue generado por una herramienta. 4 | // 5 | // Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si 6 | // se vuelve a generar el código. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace TestApplicationv2_0.WebFormTests { 11 | 12 | 13 | public partial class GetValues { 14 | 15 | /// 16 | /// Control form1. 17 | /// 18 | /// 19 | /// Campo generado automáticamente. 20 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// Control Result1Literal. 26 | /// 27 | /// 28 | /// Campo generado automáticamente. 29 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 30 | /// 31 | protected global::System.Web.UI.WebControls.Literal Result1Literal; 32 | 33 | /// 34 | /// Control Result2Literal. 35 | /// 36 | /// 37 | /// Campo generado automáticamente. 38 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 39 | /// 40 | protected global::System.Web.UI.WebControls.Literal Result2Literal; 41 | 42 | /// 43 | /// Control Result3Literal. 44 | /// 45 | /// 46 | /// Campo generado automáticamente. 47 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 48 | /// 49 | protected global::System.Web.UI.WebControls.Literal Result3Literal; 50 | 51 | /// 52 | /// Control Result4Literal. 53 | /// 54 | /// 55 | /// Campo generado automáticamente. 56 | /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. 57 | /// 58 | protected global::System.Web.UI.WebControls.Literal Result4Literal; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio. 3 | ################################################################################ 4 | 5 | *.suo 6 | /MongoSessionStateStore/obj/Debug 7 | /MongoSessionStateStore/bin/Debug 8 | /packages 9 | /TestApplicationv2_0/bin 10 | /TestApplicationv2_0/obj/Debug 11 | *.user 12 | /TestApplicationv2_0.Tests/bin/Debug 13 | /TestApplicationv2_0.Tests/obj/Debug 14 | /TestApplication_PersonalizedHelpers.Tests/bin/Debug 15 | /TestApplication_PersonalizedHelpers.Tests/obj/Debug 16 | /TestApplication_RAWSerialization/bin 17 | /TestApplication_PersonalizedHelpers/bin 18 | /TestApplication_PersonalizedHelpers/obj/Debug/TestApplication_PersonalizedHelpers.pdb 19 | /TestApplication_PersonalizedHelpers/obj/Debug/TestApplication_PersonalizedHelpers.dll 20 | /TestApplication_PersonalizedHelpers/obj/Debug/TestApplication_PersonalizedHelpers.csprojResolveAssemblyReference.cache 21 | /TestApplication_PersonalizedHelpers/obj/Debug/TestApplication_PersonalizedHelpers.csproj.FileListAbsolute.txt 22 | /TestApplication_PersonalizedHelpers/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs 23 | /TestApplication_PersonalizedHelpers/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs 24 | /TestApplication_PersonalizedHelpers/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs 25 | /TestApplication_PersonalizedHelpers/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache 26 | /TestApplication_RAWSerialization/obj/Debug 27 | /TestApplication_RAWSerialization.Tests/bin/Debug 28 | /TestApplication_RAWSerialization.Tests/obj/Debug 29 | /TestApplication_RAWSerializationWithoutTypeReference/bin 30 | /TestApplication_RAWSerializationWithoutTypeReference/obj/Debug 31 | .vs 32 | TestApplication_PersonalizedHelpers/obj 33 | UpgradeLog.htm 34 | UpgradeLog2.htm 35 | /MongoSessionStateStore/Core/Compression 36 | /TestApplication_PersonalizedHelpers/Core/Compression 37 | /TestApplication_PersonalizedHelpers/mongocrypt.dll 38 | /TestApplication_PersonalizedHelpers/libmongocrypt.so 39 | /TestApplication_PersonalizedHelpers/libmongocrypt.dylib 40 | /MongoSessionStateStore/mongocrypt.dll 41 | /MongoSessionStateStore/libmongocrypt.so 42 | /MongoSessionStateStore/libmongocrypt.dylib 43 | /MongoSessionStateStore/obj/Release 44 | /MongoSessionStateStore/bin/Release 45 | /TestApplicationv2_0/obj/Release 46 | /TestApplicationv2_0.Tests/obj/Release 47 | /TestApplicationv2_0.Tests/bin/Release 48 | /TestApplication_PersonalizedHelpers.Tests/obj/Release 49 | /TestApplication_PersonalizedHelpers.Tests/bin/Release 50 | /TestApplication_RAWSerialization/obj/Release 51 | /TestApplication_RAWSerialization.Tests/obj/Release 52 | /TestApplication_RAWSerialization.Tests/bin/Release 53 | /TestApplication_RAWSerializationWithoutTypeReference/obj/Release 54 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers.Tests/TestPersonalizedHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System.Net; 4 | 5 | namespace TestApplication_PersonalizedHelpers.Tests 6 | { 7 | [TestClass] 8 | public class TestPersonalizedHelper 9 | { 10 | //This test case is quite huge, but the order in the requests is important. 11 | [TestMethod] 12 | public void TestMvcPersonalizedHelper() 13 | { 14 | CookieContainer cookie = new CookieContainer(); 15 | string url1 = string.Format(TestApplication_PersonalizedHelpers_Helpers.BASE_URL_MVC, 16 | TestApplication_PersonalizedHelpers_Helpers.CONTROLLER, "SetTestPersonalizedHelper"); 17 | string url2 = string.Format(TestApplication_PersonalizedHelpers_Helpers.BASE_URL_MVC, 18 | TestApplication_PersonalizedHelpers_Helpers.CONTROLLER, "GetTestPersonalizedHelper"); 19 | string url3 = string.Format(TestApplication_PersonalizedHelpers_Helpers.BASE_URL_MVC, 20 | TestApplication_PersonalizedHelpers_Helpers.CONTROLLER, "ChangeHelperToFullPersonalized"); 21 | string url4 = string.Format(TestApplication_PersonalizedHelpers_Helpers.BASE_URL_FORMS, 22 | TestApplication_PersonalizedHelpers_Helpers.WEB_FORM1); 23 | string url5 = string.Format(TestApplication_PersonalizedHelpers_Helpers.BASE_URL_FORMS, 24 | TestApplication_PersonalizedHelpers_Helpers.WEB_FORM2); 25 | string url6 = string.Format(TestApplication_PersonalizedHelpers_Helpers.BASE_URL_MVC, 26 | TestApplication_PersonalizedHelpers_Helpers.CONTROLLER, "ChangeHelperToPartialPersonalized"); 27 | 28 | string result1 = TestApplication_PersonalizedHelpers_Helpers.DoRequest(url1, cookie); 29 | string result2 = TestApplication_PersonalizedHelpers_Helpers.DoRequest(url2, cookie); 30 | string result3 = TestApplication_PersonalizedHelpers_Helpers.DoRequest(url3, cookie); 31 | string result4 = TestApplication_PersonalizedHelpers_Helpers.DoRequest(url4, cookie); 32 | string result5 = TestApplication_PersonalizedHelpers_Helpers.DoRequest(url5, cookie); 33 | string result6 = TestApplication_PersonalizedHelpers_Helpers.DoRequest(url6, cookie); 34 | 35 | StringAssert.Contains(result1, 36 | "This is a sample class of a partial personalized helper"); 37 | StringAssert.Contains(result2, 38 | "This is a sample class of a partial personalized helper"); 39 | StringAssert.Contains(result3, "OK"); 40 | StringAssert.Contains(result4, 41 | "This is a sample class of a full personalized helper"); 42 | StringAssert.Contains(result5, 43 | "This is a sample class of a full personalized helper"); 44 | StringAssert.Contains(result6, "OK"); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /TestApplicationv2_0.Tests/SerializingJsonObjects_v2_0.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System.Net; 4 | 5 | namespace TestApplication2_0.Tests 6 | { 7 | [TestClass] 8 | public class SerializingJsonObjects_v2_0 9 | { 10 | [TestMethod] 11 | public void JSonObectWithList() 12 | { 13 | CookieContainer cookieContainer = new CookieContainer(); 14 | string url = 15 | TestHelpers_v2_0.BASE_URL + 16 | TestHelpers_v2_0.SET_SESSION_VAL_JSON_SERIALIZELIST, 17 | url2 = 18 | TestHelpers_v2_0.BASE_URL + 19 | TestHelpers_v2_0.PRINT_SESSION_VAL_JSON_SERIALIZELIST; 20 | 21 | TestHelpers_v2_0.DoRequest(url, cookieContainer); 22 | string result = TestHelpers_v2_0.DoRequest(url2, cookieContainer); 23 | string expectedResultPart = @"
24 | PersonPetsList 25 | 26 |
27 | Name 28 |
29 |
30 | Marc 31 |
32 | 33 |
34 | Surname 35 |
36 |
37 | Cortada 38 |
39 | 40 |
41 | City 42 |
43 |
44 | Barcelona 45 |
46 |
47 | Barcelona 48 |
49 | 50 |
51 | Dog 52 |
53 | 54 |
55 | Cat 56 |
57 | 58 |
59 | Shark 60 |
61 | 62 |
63 | "; 64 | StringAssert.Contains(result, expectedResultPart); 65 | } 66 | 67 | [TestMethod] 68 | public void JSonObject() 69 | { 70 | CookieContainer cookieContainer = new CookieContainer(); 71 | string url = 72 | TestHelpers_v2_0.BASE_URL + 73 | TestHelpers_v2_0.SET_SESSION_VAL_JSON_SERIALIZEPERSON, 74 | url2 = 75 | TestHelpers_v2_0.BASE_URL + 76 | TestHelpers_v2_0.PRINT_SESSION_VAL_JSON_SERIALIZEPERSON; 77 | 78 | TestHelpers_v2_0.DoRequest(url, cookieContainer); 79 | string result = TestHelpers_v2_0.DoRequest(url2, cookieContainer); 80 | string expectedResultPart = @"Person 81 | 82 |
83 | Name 84 |
85 |
86 | Marc 87 |
88 | 89 |
90 | Surname 91 |
92 |
93 | Cortada 94 |
95 | 96 |
97 | City 98 |
99 |
100 | Barcelona 101 |
"; 102 | StringAssert.Contains(result, expectedResultPart); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /TestApplicationv2_0/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /TestApplication_RAWSerializationWithoutTypeReference/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /TestApplicationv2_0.Tests/ElectionsTest_v2_0.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System.Collections.Generic; 4 | using System.Net; 5 | 6 | namespace TestApplication2_0.Tests 7 | { 8 | [TestClass] 9 | public class ElectionsTest_v2_0 10 | { 11 | private Object _lockObj = new Object(); 12 | private bool _testOk = true; 13 | private string _errorMessage = ""; 14 | private int nCall = 0; 15 | private int nBlock = 0; 16 | 17 | public void SingleSetValueThread() 18 | { 19 | try 20 | { 21 | CookieContainer cookieContainer = new CookieContainer(); 22 | string textToSet = "valueSettedInSession" + (nBlock.ToString() + "-" + nCall.ToString()); 23 | string url = 24 | TestHelpers_v2_0.DEFAULT_WITH_HELPERS + 25 | TestHelpers_v2_0.SET_SESSION_VAL_STRING + 26 | textToSet, 27 | url2 = 28 | TestHelpers_v2_0.DEFAULT_WITH_HELPERS + 29 | TestHelpers_v2_0.PRINT_SESSION_VAL_STRING; 30 | TestHelpers_v2_0.DoRequest(url, cookieContainer); 31 | string result = TestHelpers_v2_0.DoRequest(url2, cookieContainer); 32 | lock (_lockObj) 33 | { 34 | if ((_testOk) && 35 | (!result.Contains(string.Format("{0}", textToSet)))) 36 | { 37 | _testOk = false; 38 | _errorMessage = "Failed. Bad content" + Environment.NewLine + result; 39 | } 40 | } 41 | } 42 | catch (Exception e) 43 | { 44 | lock (_lockObj) 45 | { 46 | _testOk = false; 47 | _errorMessage = "Http Exception" + e.Message; 48 | } 49 | } 50 | } 51 | 52 | public void SendMultipleCallsAsync() 53 | { 54 | const int MAX_CALLS = 1000; 55 | nBlock++; 56 | List tasks = new List(); 57 | for (nCall = 0; nCall < MAX_CALLS; nCall++) 58 | { 59 | System.Threading.Thread t = new System.Threading.Thread(SingleSetValueThread); 60 | t.Start(); 61 | tasks.Add(t); 62 | } 63 | for (nCall = 0; nCall < MAX_CALLS; nCall++) 64 | { 65 | tasks[nCall].Join(); 66 | } 67 | } 68 | 69 | /// 70 | /// During this two minutes sending requests to a web server 71 | /// you can try to disconnect, switch off and/or kill 72 | /// the process of the replica set primary server. 73 | /// During this time requests and responses will be send continuously and 74 | /// the get an set value will be compared. If the elections process 75 | /// works well the session state will work only with a pause during 76 | /// the election process but without any interruption. 77 | /// 78 | [TestMethod] 79 | public void SendRequestsTwoMinutes() 80 | { 81 | DateTime final = DateTime.Now.AddMinutes(2); 82 | 83 | while ((_testOk) && (DateTime.Now < final)) 84 | SendMultipleCallsAsync(); 85 | 86 | Assert.IsTrue(_testOk, _errorMessage); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /MongoSessionStateStore/SessionHelpers/SessionHelper.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using MongoDB.Bson.Serialization; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace MongoSessionStateStore.SessionHelpers 10 | { 11 | public class SessionHelper : ISessionHelper 12 | { 13 | public const string DECIMAL_EXCEPTION_MESSAGE = "Decimal types are not supported for serialization in Mongo.Session"; 14 | 15 | public virtual T getObjValue(object sessionObj) 16 | { 17 | if (sessionObj == null) 18 | return default(T); 19 | 20 | if (sessionObj is T) 21 | return (T)sessionObj; 22 | 23 | if (sessionObj is BsonDocument) 24 | return (T)BsonSerializer.Deserialize(sessionObj as BsonDocument); 25 | 26 | var type = typeof(T); 27 | 28 | if ((type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) 29 | && (Nullable.GetUnderlyingType(type).IsEnum)) 30 | { 31 | if ((sessionObj == null) || (string.IsNullOrEmpty(sessionObj.ToString()))) 32 | return default(T); 33 | 34 | BsonValue bsonObject = sessionObj as BsonValue; 35 | if (bsonObject != null) 36 | return (T)Enum.Parse( 37 | Nullable.GetUnderlyingType(type), 38 | (string)BsonTypeMapper.MapToDotNetValue(bsonObject)); 39 | else 40 | return (T)Enum.Parse( 41 | Nullable.GetUnderlyingType(type), 42 | (string)sessionObj); 43 | } 44 | 45 | if (sessionObj is BsonValue) 46 | return (T)BsonTypeMapper.MapToDotNetValue(sessionObj as BsonValue); 47 | 48 | return default(T); 49 | } 50 | 51 | public virtual T Mongo(System.Web.HttpSessionStateBase session, string key) 52 | { 53 | var sessionObj = session[key]; 54 | return getObjValue(sessionObj); 55 | } 56 | 57 | public virtual void Mongo(System.Web.HttpSessionStateBase session, string key, T newValue) 58 | { 59 | var type = typeof(T); 60 | if ((type == typeof(decimal?)) || (type == typeof(decimal))) 61 | throw new Exception(DECIMAL_EXCEPTION_MESSAGE); 62 | 63 | if ((type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) 64 | && (Nullable.GetUnderlyingType(type).IsEnum)) 65 | session[key] = newValue.ToString(); 66 | else 67 | session[key] = newValue; 68 | } 69 | 70 | public virtual T Mongo(System.Web.SessionState.HttpSessionState session, string key) 71 | { 72 | var sessionObj = session[key]; 73 | return getObjValue(sessionObj); 74 | } 75 | 76 | public virtual void Mongo(System.Web.SessionState.HttpSessionState session, string key, T newValue) 77 | { 78 | var type = typeof(T); 79 | if ((type == typeof(decimal?)) || (type == typeof(decimal))) 80 | throw new Exception(DECIMAL_EXCEPTION_MESSAGE); 81 | 82 | if ((type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) 83 | && (Nullable.GetUnderlyingType(type).IsEnum)) 84 | session[key] = newValue.ToString(); 85 | else 86 | session[key] = newValue; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /MongoSessionStateStore/Serialization/RawSerialization.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Runtime.Serialization; 7 | using System.Runtime.Serialization.Formatters.Binary; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Web; 11 | using System.Web.SessionState; 12 | 13 | namespace MongoSessionStateStore.Serialization 14 | { 15 | internal class RawSerialization : ISerialization 16 | { 17 | public BsonArray Serialize(SessionStateStoreData sessionData) 18 | { 19 | BsonArray bsonArraySession = new BsonArray(); 20 | 21 | for (int i = 0; i < sessionData.Items.Count; i++) 22 | { 23 | string key = sessionData.Items.Keys[i]; 24 | var sessionObj = sessionData.Items[key]; 25 | 26 | if (sessionObj == null) 27 | { 28 | bsonArraySession.Add(new BsonDocument(key, BsonNull.Value)); 29 | } 30 | else 31 | { 32 | using (var ms = new MemoryStream()) 33 | { 34 | IFormatter formatter = new BinaryFormatter(); 35 | string serializedItem; 36 | if (sessionObj is UnSerializedItem) 37 | { 38 | serializedItem = ((UnSerializedItem)sessionObj).SerializedString; 39 | } 40 | else 41 | { 42 | formatter.Serialize(ms, sessionObj); 43 | serializedItem = Convert.ToBase64String(ms.ToArray()); 44 | } 45 | bsonArraySession.Add(new BsonDocument(key, serializedItem)); 46 | } 47 | } 48 | } 49 | 50 | return bsonArraySession; 51 | } 52 | 53 | public SessionStateStoreData Deserialize( 54 | HttpContext context, 55 | BsonArray bsonSerializedItems, 56 | int timeout) 57 | { 58 | var sessionItems = new SessionStateItemCollection(); 59 | 60 | foreach (var serializedValues in bsonSerializedItems.Values) 61 | { 62 | var document = serializedValues as BsonDocument; 63 | string name = document.Names.FirstOrDefault(); 64 | var value = document.Values.FirstOrDefault(); 65 | 66 | if (value == BsonNull.Value) 67 | { 68 | sessionItems[name] = null; 69 | } 70 | else 71 | { 72 | string valueSerialized = document.Values.FirstOrDefault().AsString; 73 | try 74 | { 75 | using (var ms = new MemoryStream(Convert.FromBase64String(valueSerialized))) 76 | { 77 | IFormatter formatter = new BinaryFormatter(); 78 | var item = formatter.Deserialize(ms); 79 | sessionItems[name] = item; 80 | } 81 | } 82 | catch (SerializationException) 83 | { 84 | sessionItems[name] = new UnSerializedItem { SerializedString = valueSerialized }; 85 | } 86 | } 87 | } 88 | 89 | return new SessionStateStoreData(sessionItems, 90 | SessionStateUtility.GetSessionStaticObjects(context), 91 | timeout); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /MongoSessionStateStore/SessionHelpers/MongoSessionHelpers.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using MongoDB.Bson.Serialization; 3 | using MongoSessionStateStore.SessionHelpers; 4 | using System; 5 | using System.Web; 6 | using System.Web.SessionState; 7 | 8 | namespace MongoSessionStateStore.SessionHelpers 9 | { 10 | internal static class MongoSessionUserHelpers 11 | { 12 | static internal ISessionHelper __helper; 13 | 14 | static MongoSessionUserHelpers() 15 | { 16 | __helper = new SessionHelper(); 17 | } 18 | 19 | internal static void SetHelper(ISessionHelper helper) 20 | { 21 | __helper = helper; 22 | } 23 | 24 | internal static T getObjValue(object sessionObj) 25 | { 26 | return __helper.getObjValue(sessionObj); 27 | } 28 | } 29 | } 30 | 31 | namespace System.Web.Mvc 32 | { 33 | public static class MongoSessionUserHelpersMvc 34 | { 35 | public static void SetHelper(ISessionHelper helper) 36 | { 37 | MongoSessionUserHelpers.SetHelper(helper); 38 | } 39 | 40 | /// 41 | /// Gets the session value stored in MongoDB. 42 | /// 43 | /// Type of the value to get. 44 | /// HttpSessionStateBase object for MVC pages. 45 | /// The session key name. 46 | /// The object requested. Null if not exists. 47 | public static T Mongo( 48 | this HttpSessionStateBase session, 49 | string key) 50 | { 51 | return MongoSessionUserHelpers.__helper.Mongo(session, key); 52 | } 53 | 54 | /// 55 | /// Sets the session value to store in MongoDB. 56 | /// 57 | /// Type of value to store. 58 | /// HttpSessionStateBase object for MVC pages. 59 | /// The session key name. 60 | /// The value to store. 61 | public static void Mongo( 62 | this HttpSessionStateBase session, 63 | string key, 64 | T newValue) 65 | { 66 | MongoSessionUserHelpers.__helper.Mongo(session, key, newValue); 67 | } 68 | } 69 | } 70 | 71 | namespace System.Web 72 | { 73 | public static class MongoSessionUserHelpersWeb 74 | { 75 | public static void SetHelper(ISessionHelper helper) 76 | { 77 | MongoSessionUserHelpers.SetHelper(helper); 78 | } 79 | /// 80 | /// Gets the session value stored in MongoDB. 81 | /// 82 | /// Type of the value to get. 83 | /// HttpSessionState object for WebForm pages. 84 | /// The session key name. 85 | /// The object requested. Null if not exists. 86 | public static T Mongo( 87 | this HttpSessionState session, 88 | string key) 89 | { 90 | return MongoSessionUserHelpers.__helper.Mongo(session, key); 91 | } 92 | 93 | /// 94 | /// Sets the session value to store in MongoDB. 95 | /// 96 | /// Type of value to store. 97 | /// HttpSessionState object for WebForm pages. 98 | /// The session key name. 99 | /// The value to store. 100 | public static void Mongo( 101 | this HttpSessionState session, 102 | string key, 103 | T newValue) 104 | { 105 | MongoSessionUserHelpers.__helper.Mongo(session, key, newValue); 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /TestApplicationv2_0/Controllers/DefaultController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using TestApplicationv2_0.Models; 7 | using MongoDB.Bson.Serialization; 8 | using MongoDB.Bson; 9 | 10 | namespace TestApplicationv2_0.Controllers 11 | { 12 | public class DefaultController : Controller 13 | { 14 | // 15 | // GET: /Default/ 16 | 17 | public ActionResult Index() 18 | { 19 | Session["value"] = "Hi"; 20 | return View(); 21 | } 22 | 23 | public ActionResult PrintSessionVal() 24 | { 25 | string val = (Session["value"] == null) ? "" : Session["value"].ToString(); 26 | ViewBag.sessionVal = val; 27 | return View(); 28 | } 29 | 30 | public ActionResult PrintSessionValDouble() 31 | { 32 | var val = Session["value"] as BsonValue; 33 | double dobVal = (double)BsonTypeMapper.MapToDotNetValue(val); 34 | ViewBag.sessionVal = dobVal.ToString("G"); 35 | return View("~/Views/Default/PrintSessionVal.aspx"); 36 | } 37 | 38 | public ActionResult SetSessionValInt(int newSesVal = 0) 39 | { 40 | Session["value"] = newSesVal; 41 | return View("~/Views/Default/SetSessionVal.aspx"); 42 | } 43 | 44 | public ActionResult SetSessionValBool(bool newSesVal = false) 45 | { 46 | Session["value"] = newSesVal; 47 | return View("~/Views/Default/SetSessionVal.aspx"); 48 | } 49 | 50 | public ActionResult SetSessionValDouble() 51 | { 52 | double newSesVal = 3.1416F; 53 | Session["value"] = newSesVal; 54 | return View("~/Views/Default/SetSessionVal.aspx"); 55 | } 56 | 57 | public ActionResult SetSessionVal(string newSesVal = "") 58 | { 59 | Session["value"] = newSesVal; 60 | return View(); 61 | } 62 | 63 | public ActionResult SessionAbandon() 64 | { 65 | Session.Abandon(); 66 | return View(); 67 | } 68 | 69 | public ActionResult SerializePerson( 70 | string name = "Marc", 71 | string surname = "Cortada", 72 | string city = "Barcelona") 73 | { 74 | Person p = new Person() 75 | { 76 | Name = name, 77 | Surname = surname, 78 | City = city 79 | }; 80 | 81 | Session["person"] = p; 82 | 83 | return View(); 84 | } 85 | 86 | public ActionResult GetSerializedPerson() 87 | { 88 | Person p = new Person(); 89 | if (Session["person"] != null) 90 | { 91 | var obj = Session["person"] as BsonDocument; 92 | if (obj != null) 93 | p = BsonSerializer.Deserialize(obj); 94 | } 95 | return View(p); 96 | } 97 | 98 | public ActionResult SerializePersonWithLists( 99 | string name = "Marc", 100 | string surname = "Cortada", 101 | string city = "Barcelona") 102 | { 103 | PersonPetsList p = new PersonPetsList() 104 | { 105 | Name = name, 106 | Surname = surname, 107 | City = city, 108 | PetsList = new List() { "Dog", "Cat", "Shark" } 109 | }; 110 | 111 | Session["personWithPetsList"] = p; 112 | 113 | return View(); 114 | } 115 | 116 | public ActionResult GetSerializedPersonWithPets() 117 | { 118 | PersonPetsList p = new PersonPetsList(); 119 | if (Session["personWithPetsList"] != null) 120 | { 121 | var obj = Session["personWithPetsList"] as BsonDocument; 122 | if (obj != null) 123 | p = BsonSerializer.Deserialize(obj); 124 | } 125 | return View(p); 126 | } 127 | 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization.Tests/PrimitiveTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System.Net; 4 | 5 | namespace TestApplication_RAWSerialization.Tests 6 | { 7 | [TestClass] 8 | public class PrimitiveTypes 9 | { 10 | 11 | [TestMethod] 12 | public void TestInt() 13 | { 14 | CookieContainer cookie = new CookieContainer(); 15 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 16 | TestApplication_RAW_Helpers.CONTROLLER, "SetIntVal"); 17 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 18 | TestApplication_RAW_Helpers.CONTROLLER, "GetIntVal"); 19 | 20 | string result = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 21 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 22 | StringAssert.Contains(result, "3"); 23 | StringAssert.Contains(result2, "3"); 24 | } 25 | 26 | [TestMethod] 27 | public void TestNullableInt() 28 | { 29 | CookieContainer cookie = new CookieContainer(); 30 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 31 | TestApplication_RAW_Helpers.CONTROLLER, "SetIntNullableVal"); 32 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 33 | TestApplication_RAW_Helpers.CONTROLLER, "GetIntNullableVal"); 34 | 35 | string result = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 36 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 37 | StringAssert.Contains(result, "3"); 38 | StringAssert.Contains(result2, "3"); 39 | } 40 | 41 | [TestMethod] 42 | public void TestDouble() 43 | { 44 | CookieContainer cookie = new CookieContainer(); 45 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 46 | TestApplication_RAW_Helpers.CONTROLLER, "SetDoubleVal"); 47 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 48 | TestApplication_RAW_Helpers.CONTROLLER, "GetDoubleVal"); 49 | 50 | string result = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 51 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 52 | StringAssert.Contains(result, "3,1416"); 53 | StringAssert.Contains(result2, "3,1416"); 54 | } 55 | 56 | [TestMethod] 57 | public void TestNullInt() 58 | { 59 | CookieContainer cookie = new CookieContainer(); 60 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 61 | TestApplication_RAW_Helpers.CONTROLLER, "SetIntNullVal"); 62 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 63 | TestApplication_RAW_Helpers.CONTROLLER, "GetIntNullVal"); 64 | 65 | string result = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 66 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 67 | StringAssert.Contains(result, "OK"); 68 | StringAssert.Contains(result2, "OK"); 69 | } 70 | 71 | [TestMethod] 72 | public void TestString() 73 | { 74 | CookieContainer cookie = new CookieContainer(); 75 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 76 | TestApplication_RAW_Helpers.CONTROLLER, "SetStringVal"); 77 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 78 | TestApplication_RAW_Helpers.CONTROLLER, "GetStringVal"); 79 | 80 | string result1 = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 81 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 82 | StringAssert.Contains(result1, "Barcelona"); 83 | StringAssert.Contains(result2, "Barcelona"); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /MongoSessionStateStore.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Web 4 | VisualStudioVersion = 12.0.30501.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoSessionStateStore", "MongoSessionStateStore\MongoSessionStateStore.csproj", "{2F0DD54F-6EF0-4DDD-9737-6D174B9E4E9D}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplicationv2_0_", "TestApplicationv2_0\TestApplicationv2_0.csproj", "{2498B537-7ECE-4066-B098-26588275B062}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplicationv2_0.Tests", "TestApplicationv2_0.Tests\TestApplicationv2_0.Tests.csproj", "{DA8558A2-7942-463A-A84D-86D25903E47B}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication_RAWSerialization_", "TestApplication_RAWSerialization\TestApplication_RAWSerialization.csproj", "{13161286-7BFA-4290-A4A9-937156F53AF8}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication_RAWSerialization.Tests", "TestApplication_RAWSerialization.Tests\TestApplication_RAWSerialization.Tests.csproj", "{1AC4B4D1-CDAF-4B9B-8BA8-0940CEF2E6FA}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication_RAWSerializationWithoutTypeReference", "TestApplication_RAWSerializationWithoutTypeReference\TestApplication_RAWSerializationWithoutTypeReference.csproj", "{D8DD5EB3-1775-4F25-8165-6CFEFD3052A0}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication_PersonalizedHelpers_", "TestApplication_PersonalizedHelpers\TestApplication_PersonalizedHelpers.csproj", "{807CA175-FDD1-4DD0-9A65-87AEAA634D8E}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication_PersonalizedHelpers.Tests", "TestApplication_PersonalizedHelpers.Tests\TestApplication_PersonalizedHelpers.Tests.csproj", "{693617CC-FEC3-4ED7-AAB9-B3674221881F}" 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|Any CPU = Debug|Any CPU 25 | Release|Any CPU = Release|Any CPU 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {2F0DD54F-6EF0-4DDD-9737-6D174B9E4E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {2F0DD54F-6EF0-4DDD-9737-6D174B9E4E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {2F0DD54F-6EF0-4DDD-9737-6D174B9E4E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {2F0DD54F-6EF0-4DDD-9737-6D174B9E4E9D}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {2498B537-7ECE-4066-B098-26588275B062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {2498B537-7ECE-4066-B098-26588275B062}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {2498B537-7ECE-4066-B098-26588275B062}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {2498B537-7ECE-4066-B098-26588275B062}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {DA8558A2-7942-463A-A84D-86D25903E47B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {DA8558A2-7942-463A-A84D-86D25903E47B}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {DA8558A2-7942-463A-A84D-86D25903E47B}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {DA8558A2-7942-463A-A84D-86D25903E47B}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {13161286-7BFA-4290-A4A9-937156F53AF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {13161286-7BFA-4290-A4A9-937156F53AF8}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {13161286-7BFA-4290-A4A9-937156F53AF8}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {13161286-7BFA-4290-A4A9-937156F53AF8}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {1AC4B4D1-CDAF-4B9B-8BA8-0940CEF2E6FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {1AC4B4D1-CDAF-4B9B-8BA8-0940CEF2E6FA}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {1AC4B4D1-CDAF-4B9B-8BA8-0940CEF2E6FA}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {1AC4B4D1-CDAF-4B9B-8BA8-0940CEF2E6FA}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {D8DD5EB3-1775-4F25-8165-6CFEFD3052A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {D8DD5EB3-1775-4F25-8165-6CFEFD3052A0}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {D8DD5EB3-1775-4F25-8165-6CFEFD3052A0}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {D8DD5EB3-1775-4F25-8165-6CFEFD3052A0}.Release|Any CPU.Build.0 = Release|Any CPU 52 | {807CA175-FDD1-4DD0-9A65-87AEAA634D8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {807CA175-FDD1-4DD0-9A65-87AEAA634D8E}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {807CA175-FDD1-4DD0-9A65-87AEAA634D8E}.Release|Any CPU.ActiveCfg = Release|Any CPU 55 | {807CA175-FDD1-4DD0-9A65-87AEAA634D8E}.Release|Any CPU.Build.0 = Release|Any CPU 56 | {693617CC-FEC3-4ED7-AAB9-B3674221881F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 57 | {693617CC-FEC3-4ED7-AAB9-B3674221881F}.Debug|Any CPU.Build.0 = Debug|Any CPU 58 | {693617CC-FEC3-4ED7-AAB9-B3674221881F}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {693617CC-FEC3-4ED7-AAB9-B3674221881F}.Release|Any CPU.Build.0 = Release|Any CPU 60 | EndGlobalSection 61 | GlobalSection(SolutionProperties) = preSolution 62 | HideSolutionNode = FALSE 63 | EndGlobalSection 64 | EndGlobal 65 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization.Tests/ObjectTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System.Net; 4 | 5 | namespace TestApplication_RAWSerialization.Tests 6 | { 7 | [TestClass] 8 | public class ObjectTypes 9 | { 10 | [TestMethod] 11 | public void TestObjects() 12 | { 13 | CookieContainer cookie = new CookieContainer(); 14 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 15 | TestApplication_RAW_Helpers.CONTROLLER, "GetAndSetSameRequestObjects"); 16 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 17 | TestApplication_RAW_Helpers.CONTROLLER, "GetObjects"); 18 | 19 | string result1 = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 20 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 21 | StringAssert.Contains(result1, "True"); 22 | StringAssert.Contains(result2, "True"); 23 | } 24 | 25 | [TestMethod] 26 | public void TestObjectsWithOutType() 27 | { 28 | CookieContainer cookie = new CookieContainer(); 29 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 30 | TestApplication_RAW_Helpers.CONTROLLER, "GetAndSetSameRequestObjects"); 31 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 32 | "GetWithoutType", "Index"); 33 | 34 | string result1 = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 35 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 36 | StringAssert.Contains(result1, "True"); 37 | StringAssert.Contains(result2, "True"); 38 | } 39 | 40 | [TestMethod] 41 | public void TestObjectsWithOutTypeExternalProject() 42 | { 43 | CookieContainer cookie = new CookieContainer(); 44 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 45 | TestApplication_RAW_Helpers.CONTROLLER, "GetAndSetSameRequestObjects"); 46 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL_2, 47 | "Home", "Index"); 48 | 49 | string result1 = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 50 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 51 | StringAssert.Contains(result1, "True"); 52 | StringAssert.Contains(result2, "True"); 53 | } 54 | 55 | [TestMethod] 56 | public void TestObjectsWithOutTypeExternalProjectAndRequestToFirstProject() 57 | { 58 | CookieContainer cookie = new CookieContainer(); 59 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 60 | TestApplication_RAW_Helpers.CONTROLLER, "GetAndSetSameRequestObjects"); 61 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL_2, 62 | TestApplication_RAW_Helpers.CONTROLLER, "Index"); 63 | string url3 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 64 | TestApplication_RAW_Helpers.CONTROLLER, "GetObjects"); 65 | string url4 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 66 | TestApplication_RAW_Helpers.CONTROLLER2, "Index"); 67 | 68 | string result1 = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 69 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 70 | string result3 = TestApplication_RAW_Helpers.DoRequest(url3, cookie); 71 | string result4 = TestApplication_RAW_Helpers.DoRequest(url4, cookie); 72 | 73 | StringAssert.Contains(result1, "True"); 74 | StringAssert.Contains(result2, "True"); 75 | StringAssert.Contains(result3, "True"); 76 | StringAssert.Contains(result4, "True"); 77 | } 78 | 79 | [TestMethod] 80 | public void TestObjectsNullValues() 81 | { 82 | CookieContainer cookie = new CookieContainer(); 83 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 84 | TestApplication_RAW_Helpers.CONTROLLER, "SetNullObject"); 85 | string url2 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 86 | TestApplication_RAW_Helpers.CONTROLLER, "GetNullObject"); 87 | 88 | string result1 = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 89 | string result2 = TestApplication_RAW_Helpers.DoRequest(url2, cookie); 90 | 91 | StringAssert.Contains(result1, "OK"); 92 | StringAssert.Contains(result2, "OK"); 93 | } 94 | 95 | [TestMethod] 96 | public void TestGetNonExistingKey() 97 | { 98 | CookieContainer cookie = new CookieContainer(); 99 | string url1 = string.Format(TestApplication_RAW_Helpers.BASE_URL, 100 | TestApplication_RAW_Helpers.CONTROLLER, "GetNonExistingKey"); 101 | 102 | string result1 = TestApplication_RAW_Helpers.DoRequest(url1, cookie); 103 | 104 | StringAssert.Contains(result1, "OK"); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | This project is not built for ASP.NET Core, if you need a session provider for ASP.NET Core [check this out](https://github.com/MarkCBB/aspnet-mongodb-session-sample#aspnet-core-mongodb-session-sample). 2 | 3 | Usage 4 | ===== 5 | 6 | 1 - Install the [nuGet package](https://www.nuget.org/packages/MongoSessionStateStore/) into your solution. 7 | 8 | The current version is built in 4.5 version of .NET framework. To use the 4.0 version of .NET framework [install the version 2.0.0 of this controller](https://www.nuget.org/packages/MongoSessionStateStore/2.0.0) 9 | 10 | 2 - Into web.config file add a section as detailed following **set connection parameters properly.** 11 | ```xml 12 | 13 | 14 | 16 | 17 | 18 | ``` 19 | 20 | 3 - Configure the provider section as detailed following: 21 | ```xml 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | ``` 32 | 33 | **Now you can get started using MongoDB Session State Store.** 34 | 35 | Chose one of these serialization types: [Bson](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/tree/Branch_raw_serialization#bson-serialization) (default) or [RAW](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/tree/Branch_raw_serialization#raw-serialization). See the [documentation about types of serialization](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/wiki/Types-of-serialization) to select the most suitable for you and the advantages and disadvantages. 36 | 37 | ## Bson serialization (default) 38 | 39 | To get started working with Bson serialization you don't need to set any parameter to any value, it's the default serialization. 40 | 41 | A helper class is included in the assembly with static extensions. **It's strongly recommended to use these helpers** as shown in the examples. 42 | 43 | You can personalize all methods of this helper class [following these instructions](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/wiki/Customizing-the-helpers). 44 | 45 | ```C# 46 | // Sets 1314 in key named sessionKey 47 | Session.Mongo("sessionKey", 1314); 48 | 49 | // Gets the value from key named "sessionKey" 50 | int n = Session.Mongo("sessionKey"); 51 | 52 | /* Note that decimal values must be converted to double. 53 | For non primitive objects you can use the same helper methods. */ 54 | 55 | // Creates and store the object personSetted (Person type) in session key named person 56 | Person personSetted = new Person() 57 | { 58 | Name = "Marc", 59 | Surname = "Cortada", 60 | City = "Barcelona" 61 | }; 62 | Session.Mongo("person", personSetted); 63 | 64 | // Retrieves the object stored in session key named "person" 65 | Person personGetted = Session.Mongo("person"); 66 | ``` 67 | 68 | Also, for primitive types you can use a direct way (not recommended). 69 | 70 | ```C# 71 | // Set primitive value 72 | Session["counter"] = 1; 73 | 74 | //Get value from another request 75 | int n = Session["counter"]; 76 | ``` 77 | 78 | ## RAW serialization 79 | 80 | To get started working with RAW serialization you need to set the parameter SerializationType to RAW value in the web.config file. See [parameters detail](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/wiki/Web.config-parameters#parameters-detail) to view the documentation about all parameters and a complete example of the config string. 81 | 82 | ```C# 83 | // Declare the objects with Serializable attribute. 84 | [Serializable] 85 | public class Person 86 | { 87 | public string Name { get; set; } 88 | public string Surname { get; set; } 89 | public string City { get; set; } 90 | } 91 | 92 | // The usage is the same as usual 93 | Person personSet = new Person() { Name = "Marc", Surname = "Cortada", City = "Barcelona" }; 94 | Session["key"] = personSet; 95 | Person personGet = (Person)Session["key"]; 96 | // Or even better 97 | personGet = Session["key"] as Person; 98 | if (personGet != null) {...} 99 | ``` 100 | 101 | For further information read about [parameters config](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/wiki/Web.config-parameters#parameters-detail) 102 | 103 | [Here you'll find all release notes](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/wiki/Release-notes-history-and-compatibility-between-versions) 104 | 105 | **If you are moving from 3.X.X to 4.X.X, as a major release, keep in mind [these compatibility notes.](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/wiki/Release-notes-history-and-compatibility-between-versions#v400)** 106 | 107 | **If you are moving from 2.X.X to 3.X.X, as a major release, keep in mind [these compatibility notes.](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/wiki/Release-notes-history-and-compatibility-between-versions#v300)** 108 | 109 | **If you are moving from 1.X.X to 2.X.X, as a major release, keep in mind [these compatibility notes.](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/wiki/Release-notes-history-and-compatibility-between-versions#v200)** 110 | 111 | To set sessions without expiration time **do not use Session.Timeout value to 0** [disable TTL index creation](https://github.com/MarkCBB/MongoDB-ASP.NET-Session-State-Store/wiki/Web.config-parameters#autocreatettlindex) 112 | -------------------------------------------------------------------------------- /TestApplicationv2_0.Tests/TestHelpers_v2_0.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace TestApplication2_0.Tests 10 | { 11 | public static class TestHelpers_v2_0 12 | { 13 | public static string BASE_URL = "http://localhost/TestApplicationv2_0/Default/"; 14 | public static string PRINT_SESION_ACTION = "PrintSessionVal/"; 15 | public static string PRINT_SESION_DOUBLE = "PrintSessionValDouble/"; 16 | public static string SET_SESSION_ACTION = "SetSessionVal/"; 17 | public static string SESSION_ABANDON_ACTION = "SessionAbandon/"; 18 | public static string SET_SESSION_VAL_INT = "SetSessionValInt/"; 19 | public static string SET_SESSION_VAL_BOOL = "SetSessionValBool/"; 20 | public static string SET_SESSION_VAL_DOUBLE = "SetSessionValDouble/"; 21 | public static string SET_SESSION_VAL_JSON_SERIALIZEPERSON = "SerializePerson/"; 22 | public static string PRINT_SESSION_VAL_JSON_SERIALIZEPERSON = "GetSerializedPerson/"; 23 | public static string SET_SESSION_VAL_JSON_SERIALIZELIST = "SerializePersonWithLists/"; 24 | public static string PRINT_SESSION_VAL_JSON_SERIALIZELIST = "GetSerializedPersonWithPets/"; 25 | 26 | public static string BASE_URL_FORMS = "http://localhost/TestApplicationv2_0/"; 27 | public static string SET_VALUE_WEB_FORM = "WebFormTests/SetValues.aspx"; 28 | public static string GET_VALUE_WEB_FORM = "WebFormTests/GetValues.aspx"; 29 | 30 | public static string DEFAULT_WITH_HELPERS = "http://localhost/TestApplicationv2_0/DefaultWithHelpers/"; 31 | public static string DEFAULT_WITH_HELPERS_READ_ONLY_SESSION_STATE = "http://localhost/TestApplicationv2_0/ReadOnlySessionState/"; 32 | public static string GET_AND_SET_SAME_REQUEST = "GetAndSetSameRequest/"; 33 | public static string PRINT_SERIALIZED_PERSON = "PrintSessionSerializedPerson/"; 34 | public static string PRINT_SERIALIZED_PERSON_WITH_LIST = "PrintSessionSerializedPersonWithlist/"; 35 | public static string SET_SESSION_VAL_STRING = "SetSessionValString/"; 36 | public static string PRINT_SESSION_VAL_STRING = "PrintSessionValString/"; 37 | public static string SET_SESSION_VAL_DOUBLE_WITH_HELPERS = "SetSessionValDouble/"; 38 | public static string PRINT_SESSION_VAL_DOUBLE = "PrintSessionValDouble/"; 39 | public static string SET_SESSION_VAL_INT_WITH_HELPERS = "SetSessionValInt/"; 40 | public static string PRINT_SESSION_VAL_INT = "PrintSessionValInt/"; 41 | public static string SET_SESSION_VAL_BOOL_WITH_HELPERS = "SetSessionValBool/"; 42 | public static string SET_SESSION_VAL_ENUM_VALUE_WITH_HELPERS = "SetSessionValEnum/"; 43 | public static string SET_SESSION_VAL_ENUM_NULLABLE_VALUE_WITH_HELPERS = "SetSessionValNullableEnum/"; 44 | public static string SET_SESSION_VAL_ENUM_NULL_VALUE_WITH_HELPERS = "SetSessionValNullableEnumToNull/"; 45 | public static string SET_SESSION_VAL_PERSON_NULL_VALUE_WITH_HELPERS = "SetNullPersonValue/"; 46 | public static string SET_SESSION_VAL_NULLABLE_INT_VALUE_WITH_HELPERS = "SetSessionValNullableInt/"; 47 | public static string SET_SESSION_VAL_NULLABLE_INT_NULL_VALUE_WITH_HELPERS = "SetSessionValNullableInt/"; 48 | public static string SET_SESSION_VAL_NULLABLE_DECINAL_NULL_VALUE_WITH_HELPERS = "SetNullableDecimalToNull/"; 49 | public static string SET_SESSION_VAL_DECIMAL_VALUE_WITH_HELPERS = "SetSessionValDecimal/"; 50 | public static string SET_SESSION_VAL_NULLABLE_DECIMAL_WITH_HELPERS = "SetSessionValNullableDecimal/"; 51 | public static string PRINT_SESSION_VAL_BOOL = "PrintSessionValBool/"; 52 | public static string PRINT_SESSION_VAL_ENUM_VALUE = "GetSessionValEnum/"; 53 | public static string PRINT_SESSION_VAL_ENUM_NULLABLE_VALUE = "GetSessionValNullableEnum/"; 54 | public static string PRINT_SESSION_VAL_ENUM_NULL_VALUE = "GetSessionValNullableEnumToNull/"; 55 | public static string PRINT_SESSION_VAL_PERSON_NULL_VALUE = "GetNullPersonValue/"; 56 | public static string PRINT_SESSION_VAL_NULLABLE_INT_VALUE = "GetSessionValNullableInt/"; 57 | public static string PRINT_SESSION_VAL_NULLABLE_INT_NULL_VALUE = "GetSessionValNullableInt/"; 58 | public static string PRINT_SESSION_VAL_NULLABLE_DECIMAL_NULL_VALUE = "GetNullableDecimalToNull/"; 59 | public static string PRINT_SESSION_VAL_DECIMAL_VALUE = "GetSessionValDecimal/"; 60 | public static string PRINT_SESSION_VAL_NULLABLE_DECIMAL_VALUE_WITH_HELPERS = "GetSessionValNullableDecimal/"; 61 | 62 | public static string DEFAULT_WITH_BSON = "http://localhost/TestApplicationv2_0/BsonDocument/"; 63 | public static string SET_BSON_VAL = "SetPerson/"; 64 | public static string GET_BSON_VAL = "GetPerson/"; 65 | 66 | public static string DoRequest( 67 | string url, 68 | CookieContainer cookieContainer) 69 | { 70 | HttpWebRequest request = 71 | (HttpWebRequest)WebRequest.Create(url); 72 | request.CookieContainer = cookieContainer; 73 | var stream = request.GetResponse().GetResponseStream(); 74 | StreamReader reader = new StreamReader(stream); 75 | return reader.ReadToEnd(); 76 | } 77 | 78 | public async static Task DoRequestAsync( 79 | string url, 80 | CookieContainer cookieContainer) 81 | { 82 | HttpWebRequest request = 83 | (HttpWebRequest)WebRequest.Create(url); 84 | request.CookieContainer = cookieContainer; 85 | var response = await request.GetResponseAsync(); 86 | var stream = response.GetResponseStream(); 87 | StreamReader reader = new StreamReader(stream); 88 | return await reader.ReadToEndAsync(); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /TestApplication_PersonalizedHelpers.Tests/TestApplication_PersonalizedHelpers.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 7 | 8 | 2.0 9 | {693617CC-FEC3-4ED7-AAB9-B3674221881F} 10 | Library 11 | Properties 12 | TestApplication_PersonalizedHelpers.Tests 13 | TestApplication_PersonalizedHelpers.Tests 14 | v4.8 15 | 512 16 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | True 53 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 54 | 55 | 56 | True 57 | ..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.0\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll 58 | 59 | 60 | ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll 61 | 62 | 63 | 64 | 65 | ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll 66 | 67 | 68 | 69 | 70 | True 71 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.Helpers.dll 72 | 73 | 74 | ..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll 75 | 76 | 77 | ..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.30506.0\lib\net40\System.Web.Http.WebHost.dll 78 | 79 | 80 | True 81 | ..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll 82 | 83 | 84 | True 85 | ..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll 86 | 87 | 88 | True 89 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll 90 | 91 | 92 | True 93 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll 94 | 95 | 96 | True 97 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | {807CA175-FDD1-4DD0-9A65-87AEAA634D8E} 114 | TestApplication_PersonalizedHelpers 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization.Tests/TestApplication_RAWSerialization.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 7 | 8 | 2.0 9 | {1AC4B4D1-CDAF-4B9B-8BA8-0940CEF2E6FA} 10 | Library 11 | Properties 12 | TestApplication_RAWSerialization.Tests 13 | TestApplication_RAWSerialization.Tests 14 | v4.8 15 | 512 16 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | false 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | false 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | True 57 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 58 | 59 | 60 | True 61 | ..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.0\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll 62 | 63 | 64 | ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll 65 | 66 | 67 | ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll 68 | 69 | 70 | True 71 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.Helpers.dll 72 | 73 | 74 | ..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll 75 | 76 | 77 | ..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.30506.0\lib\net40\System.Web.Http.WebHost.dll 78 | 79 | 80 | True 81 | ..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll 82 | 83 | 84 | True 85 | ..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll 86 | 87 | 88 | True 89 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll 90 | 91 | 92 | True 93 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll 94 | 95 | 96 | True 97 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | {13161286-7BFA-4290-A4A9-937156F53AF8} 115 | TestApplication_RAWSerialization 116 | 117 | 118 | 119 | 126 | -------------------------------------------------------------------------------- /TestApplicationv2_0.Tests/TestApplicationv2_0.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 7 | 8 | 2.0 9 | {DA8558A2-7942-463A-A84D-86D25903E47B} 10 | Library 11 | Properties 12 | TestApplicationv2_0.Tests 13 | TestApplicationv2_0.Tests 14 | v4.8 15 | 512 16 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | True 53 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 54 | 55 | 56 | True 57 | ..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.0\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll 58 | 59 | 60 | ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll 61 | 62 | 63 | 64 | 65 | ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll 66 | 67 | 68 | 69 | 70 | True 71 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.Helpers.dll 72 | 73 | 74 | ..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll 75 | 76 | 77 | ..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.30506.0\lib\net40\System.Web.Http.WebHost.dll 78 | 79 | 80 | True 81 | ..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll 82 | 83 | 84 | True 85 | ..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll 86 | 87 | 88 | True 89 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll 90 | 91 | 92 | True 93 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll 94 | 95 | 96 | True 97 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | {2498B537-7ECE-4066-B098-26588275B062} 119 | TestApplicationv2_0 120 | 121 | 122 | 123 | 130 | -------------------------------------------------------------------------------- /TestApplication_RAWSerialization/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using TestApplication_RAWSerialization.Models; 7 | 8 | namespace TestApplication_RAWSerialization.Controllers 9 | { 10 | public class HomeController : Controller 11 | { 12 | public const string KEY_NAME = "value"; 13 | public const string KEY_NAME2 = "value2"; 14 | public const string KEY_NAME3 = "value3"; 15 | public const string VIEW_DATA_VAL = "sessionVal"; 16 | 17 | public ActionResult SetIntVal(int val = 3) 18 | { 19 | Session["SetInteger"] = val; 20 | int valForGet = (int)Session["SetInteger"]; 21 | ViewBag.sessionVal = valForGet; 22 | return View("~/Views/Home/Index.aspx"); 23 | } 24 | 25 | public ActionResult GetIntVal() 26 | { 27 | int valForGet = (int)Session["SetInteger"]; 28 | ViewBag.sessionVal = valForGet; 29 | return View("~/Views/Home/Index.aspx"); 30 | } 31 | 32 | public ActionResult SetDoubleVal() 33 | { 34 | double val = 3.1416; 35 | Session["SetInteger"] = val; 36 | double valForGet = (double)Session["SetInteger"]; 37 | ViewBag.sessionVal = valForGet; 38 | return View("~/Views/Home/Index.aspx"); 39 | } 40 | 41 | public ActionResult GetDoubleVal() 42 | { 43 | double valForGet = (double)Session["SetInteger"]; 44 | ViewBag.sessionVal = valForGet; 45 | return View("~/Views/Home/Index.aspx"); 46 | } 47 | 48 | public ActionResult SetIntNullableVal() 49 | { 50 | int? valForSet = 3; 51 | Session["SetNullableInteger"] = valForSet; 52 | int? valForGet = (int?)Session["SetNullableInteger"]; 53 | ViewBag.sessionVal = valForGet.ToString(); 54 | return View("~/Views/Home/Index.aspx"); 55 | } 56 | 57 | public ActionResult GetIntNullableVal() 58 | { 59 | int? valForGet = (int?)Session["SetNullableInteger"]; 60 | ViewBag.sessionVal = valForGet; 61 | return View("~/Views/Home/Index.aspx"); 62 | } 63 | 64 | public ActionResult SetIntNullVal() 65 | { 66 | int? val = null; 67 | Session["SetInteger"] = val; 68 | int? valForGet = Session["SetIntegerNull"] as int?; 69 | ViewBag.sessionVal = (valForGet == null) ? "OK" : "KO"; 70 | return View("~/Views/Home/Index.aspx"); 71 | } 72 | 73 | public ActionResult GetIntNullVal() 74 | { 75 | int? valForGet = (int?)Session["SetIntegerNull"]; 76 | ViewBag.sessionVal = (valForGet == null) ? "OK" : "KO"; 77 | return View("~/Views/Home/Index.aspx"); 78 | } 79 | 80 | public ActionResult TestStaticString() 81 | { 82 | ViewBag.sessionVal = "OK"; 83 | return View("~/Views/Home/Index.aspx"); 84 | } 85 | 86 | public ActionResult SetStringVal(string val = "Barcelona") 87 | { 88 | Session["SetStringVal"] = val; 89 | string valForGet = (string)Session["SetStringVal"]; 90 | ViewBag.sessionVal = valForGet; 91 | return View("~/Views/Home/Index.aspx"); 92 | } 93 | 94 | public ActionResult GetStringVal() 95 | { 96 | string valForGet = (string)Session["SetStringVal"]; 97 | ViewBag.sessionVal = valForGet; 98 | return View("~/Views/Home/Index.aspx"); 99 | } 100 | 101 | public ActionResult GetAndSetSameRequestObjects() 102 | { 103 | Person personSet = new Person() { Name = "Marc", Surname = "Cortada", City = "Barcelona" }; 104 | Session[KEY_NAME] = personSet; 105 | 106 | PersonPetsList personPetsSet = new PersonPetsList() 107 | { 108 | Name = "Marc2", 109 | Surname = "Cortada2", 110 | PetsList = new List() { "cat", "dog" } 111 | }; 112 | Session[KEY_NAME3] = personPetsSet; 113 | 114 | Person personGet = (Person)Session[KEY_NAME]; 115 | PersonPetsList personPetsListGet = (PersonPetsList)Session[KEY_NAME3]; 116 | 117 | if ((personSet.Name == personGet.Name) && 118 | (personSet.Surname == personGet.Surname) && 119 | (personSet.City == personGet.City) && 120 | (personPetsListGet.Name == personPetsSet.Name) && 121 | (personPetsListGet.Surname == personPetsSet.Surname) && 122 | (personPetsListGet.PetsList[0] == personPetsSet.PetsList[0]) && 123 | (personPetsListGet.PetsList[1] == personPetsSet.PetsList[1])) 124 | ViewBag.sessionVal = "True"; 125 | else 126 | ViewBag.sessionVal = "False"; 127 | 128 | return View("~/Views/Home/Index.aspx"); 129 | } 130 | 131 | public ActionResult GetObjects() 132 | { 133 | Person personSet = new Person() { Name = "Marc", Surname = "Cortada", City = "Barcelona" }; 134 | 135 | PersonPetsList personPetsSet = new PersonPetsList() 136 | { 137 | Name = "Marc2", 138 | Surname = "Cortada2", 139 | PetsList = new List() { "cat", "dog" } 140 | }; 141 | 142 | Person personGet = (Person)Session[KEY_NAME]; 143 | PersonPetsList personPetsListGet = (PersonPetsList)Session[KEY_NAME3]; 144 | 145 | if ((personSet.Name == personGet.Name) && 146 | (personSet.Surname == personGet.Surname) && 147 | (personSet.City == personGet.City) && 148 | (personPetsListGet.Name == personPetsSet.Name) && 149 | (personPetsListGet.Surname == personPetsSet.Surname) && 150 | (personPetsListGet.PetsList[0] == personPetsSet.PetsList[0]) && 151 | (personPetsListGet.PetsList[1] == personPetsSet.PetsList[1])) 152 | ViewBag.sessionVal = "True"; 153 | else 154 | ViewBag.sessionVal = "False"; 155 | 156 | return View("~/Views/Home/Index.aspx"); 157 | } 158 | 159 | public ActionResult SetNullObject() 160 | { 161 | Person personSet = null; 162 | Session["PersonNull"] = personSet; 163 | Object objGet = Session["PersonNull"]; 164 | Person personGet = objGet as Person; 165 | ViewBag.sessionVal = ((personGet == null) && (objGet == null)) ? "OK" : "KO"; 166 | return View("~/Views/Home/Index.aspx"); 167 | } 168 | 169 | public ActionResult GetNullObject() 170 | { 171 | var objGet = Session["PersonNull"]; 172 | Person personGet = Session["PersonNull"] as Person; 173 | ViewBag.sessionVal = ((personGet == null) && (objGet == null)) ? "OK" : "KO"; 174 | return View("~/Views/Home/Index.aspx"); 175 | } 176 | 177 | public ActionResult GetNonExistingKey() 178 | { 179 | var obj = Session["NonExistingKey"]; 180 | ViewBag.sessionVal = (obj == null) ? "OK" : "KO"; 181 | return View("~/Views/Home/Index.aspx"); 182 | } 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /MongoSessionStateStore/MongoSessionStateStore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {2F0DD54F-6EF0-4DDD-9737-6D174B9E4E9D} 9 | Library 10 | Properties 11 | MongoSessionStateStore 12 | MongoSessionStateStore 13 | v4.5.2 14 | 512 15 | 16 | 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | false 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | false 37 | 38 | 39 | 40 | ..\packages\DnsClient.1.4.0\lib\net45\DnsClient.dll 41 | 42 | 43 | ..\packages\MongoDB.Bson.2.13.3\lib\net452\MongoDB.Bson.dll 44 | 45 | 46 | ..\packages\MongoDB.Driver.2.13.3\lib\net452\MongoDB.Driver.dll 47 | 48 | 49 | ..\packages\MongoDB.Driver.Core.2.13.3\lib\net452\MongoDB.Driver.Core.dll 50 | 51 | 52 | ..\packages\MongoDB.Libmongocrypt.1.2.2\lib\net452\MongoDB.Libmongocrypt.dll 53 | 54 | 55 | ..\packages\SharpCompress.0.23.0\lib\net45\SharpCompress.dll 56 | 57 | 58 | 59 | ..\packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll 60 | 61 | 62 | 63 | 64 | 65 | ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll 66 | 67 | 68 | ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll 69 | 70 | 71 | ..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | Designer 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}. 111 | 112 | 113 | 114 | 115 | 116 | 123 | --------------------------------------------------------------------------------