{"id":21055284,"url":"https://github.com/quintsys/web.providers.mongodbsessionstatestore","last_synced_at":"2025-03-13T23:44:42.765Z","repository":{"id":13419781,"uuid":"16108395","full_name":"quintsys/Web.Providers.MongoDBSessionStateStore","owner":"quintsys","description":"MongoDB Session State Provider","archived":false,"fork":false,"pushed_at":"2014-04-11T17:50:05.000Z","size":776,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-22T23:09:56.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quintsys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-21T16:19:05.000Z","updated_at":"2014-04-11T17:50:05.000Z","dependencies_parsed_at":"2022-09-23T12:42:35.425Z","dependency_job_id":null,"html_url":"https://github.com/quintsys/Web.Providers.MongoDBSessionStateStore","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quintsys%2FWeb.Providers.MongoDBSessionStateStore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quintsys%2FWeb.Providers.MongoDBSessionStateStore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quintsys%2FWeb.Providers.MongoDBSessionStateStore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quintsys%2FWeb.Providers.MongoDBSessionStateStore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quintsys","download_url":"https://codeload.github.com/quintsys/Web.Providers.MongoDBSessionStateStore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243500772,"owners_count":20300770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T16:42:50.973Z","updated_at":"2025-03-13T23:44:42.745Z","avatar_url":"https://github.com/quintsys.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Web.Providers.MongoDBSessionStateStore\n======================================\n\nMongoDBSessionStateStore is a custom ASP.NET Session State Provider using MongoDB as the state store.\n\n\nInstallation\n------------\n\nTo install MongoDBSessionStateStore, run the following command in the Package Manager Console:\n\n    PM\u003e Install-Package MongoDBSessionStateStore\n\n\nDocument Example\n---------------\n\nSession state is stored in a \"Sessions\" collection within a \"SessionState\" database.      \nExample session document:\n\n    {\n        \"_id\" : \"bh54lskss4ycwpreet21dr1h\",\n        \"ApplicationName\" : \"/\",\n        \"Created\" : ISODate(\"2011-04-29T21:41:41.953Z\"),\n        \"Expires\" : ISODate(\"2011-04-29T22:01:41.953Z\"),\n        \"LockDate\" : ISODate(\"2011-04-29T21:42:02.016Z\"),\n        \"LockId\" : 1,\n        \"Timeout\" : 20,\n        \"Locked\" : true,\n        \"Items\" : \"AQAAAP/8EVGVzdAgAAAABBkFkcmlhbg==\",\n        \"Flags\" : 0\n    }\n     \n\nException Handling\n------------------\n\nIf the provider encounters an exception when working with the data source, it writes the details of the exception to the Application Event Log instead of returning the exception to the ASP.NET application. This is done as a security measure to avoid private information about the data source from being exposed in the ASP.NET application.\n\nThe sample provider specifies an event Source property value of \"MongoSessionStateStore.\" Before your ASP.NET application will be able to write to the Application Event Log successfully, you will need to create the following registry key:\n   \n    HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\MongoSessionStateStore\n     \nIf you do not want the sample provider to write exceptions to the event log, then you can set the custom writeExceptionsToEventLog attribute to false in the Web.config file.\n\nmore: http://stackoverflow.com/questions/1610189/security-exception-when-writting-to-an-eventlog-from-an-asp-net-mvc-application?lq=1\n\n\n\nExpired Sessions Cleanup\n------------------------\n     \nThe session-state store provider does not provide support for the Session_OnEnd event, it does not automatically clean up expired session-item data. It is recommended that you periodically delete expired session information from the data store with the following code.:\n\n    db.Sessions.remove({\"Expires\" : {$lt : new Date() }})\n\nmore: http://stackoverflow.com/questions/1042881/why-session-end-event-not-raised-when-stateprovider-is-not-inproc\n\n\n     \nExample web.config Settings\n---------------------------\n\n    \u003cconnectionStrings\u003e\n        \u003cadd name=\"MongoDBSessionState\" connectionString=\"mongodb://localhost\" /\u003e\n    \u003c/connectionStrings\u003e\n    \u003csystem.web\u003e\n        \u003csessionState\n            timeout=\"1440\"\n            cookieless=\"false\"\n            mode=\"Custom\"\n            customProvider=\"MongoSessionStateProvider\"\u003e\n            \u003cproviders\u003e\n                \u003cadd name=\"MongoSessionStateProvider\"\n                    type=\"Quintsys.Web.Providers.MongoDBSessionStateStore.MongoDBSessionStateStoreProvider\"\n                    connectionStringName=\"MongoDBSessionState\"\n                    fsync=\"false\"\n                    replicasToWrite=\"0\"\n                    writeExceptionsToEventLog=\"false\" /\u003e\n            \u003c/providers\u003e\n        \u003c/sessionState\u003e\n    \u003c/system.web\u003e\n\n\n\u003e replicasToWrite: interpreted as the number of replicas to write to, in addition to the primary.\n\n\n    replicasToWrite = 0, will wait for the response from writing to the primary node. \n    replicasToWrite \u003e 0 will wait for the response having written to ({replicasToWrite} + 1) nodes\n    \n\n\nReferences\n----------\n\n* [Microsoft - Implementing a Session-State Store Provider] [1]\n* [Microsoft - Sample Session-State Store Provider] [2]\n* [AdaTheDev's MongoDB ASP.NET Session State Store] [3]\n\n\n[1]:http://msdn.microsoft.com/en-us/library/ms178587.aspx\n[2]:http://msdn.microsoft.com/en-us/library/ms178588.aspx\n[3]:https://github.com/AdaTheDev/MongoDB-ASP.NET-Session-State-Store\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquintsys%2Fweb.providers.mongodbsessionstatestore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquintsys%2Fweb.providers.mongodbsessionstatestore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquintsys%2Fweb.providers.mongodbsessionstatestore/lists"}