{"id":29226417,"url":"https://github.com/oscardsoto/blazorsessionprovider","last_synced_at":"2025-08-02T07:36:14.424Z","repository":{"id":219046837,"uuid":"748039043","full_name":"oscardsoto/BlazorSessionProvider","owner":"oscardsoto","description":"A Blazor Server library that handle sessions inside the application (not in the browser)","archived":false,"fork":false,"pushed_at":"2025-06-17T04:05:12.000Z","size":217,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-17T04:15:24.118Z","etag":null,"topics":["asp-net-core","blazor","blazor-server","framework","library","net-8","provider","server","session","sessions"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oscardsoto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-25T06:24:02.000Z","updated_at":"2025-06-17T04:05:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"b387cb0c-b71e-4be4-be70-208acd6fc822","html_url":"https://github.com/oscardsoto/BlazorSessionProvider","commit_stats":null,"previous_names":["oscardsoto/blazorsessionprovider"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/oscardsoto/BlazorSessionProvider","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscardsoto%2FBlazorSessionProvider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscardsoto%2FBlazorSessionProvider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscardsoto%2FBlazorSessionProvider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscardsoto%2FBlazorSessionProvider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oscardsoto","download_url":"https://codeload.github.com/oscardsoto/BlazorSessionProvider/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscardsoto%2FBlazorSessionProvider/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263287972,"owners_count":23443091,"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":["asp-net-core","blazor","blazor-server","framework","library","net-8","provider","server","session","sessions"],"created_at":"2025-07-03T08:14:06.989Z","updated_at":"2025-07-03T08:14:08.218Z","avatar_url":"https://github.com/oscardsoto.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BlazorSessionProvider\n\n## Introduction\nBlazorSessionProvider is a Blazor Server library that handle sessions inside the application. Simple to install and configure.\n\n## Requirements\n- This library works under .NET 8 and higher\n\n## Quick Install\n1. Install the package via NuGet:\n  ```console\n  dotnet add package BlazorSessionProvider --version 1.0.4\n  ```\n\n2. Add the next code line in your Blazor project, on `Program.cs`:\n  ```csharp\n  using BlazorSessionProvider;\n  var builder = WebApplication.CreateBuilder(args);\n  ...\n  builder.Services.AddSessionProvider(config =\u003e {\n      config.TimeDelay           = new TimeSpan(0, 0, 30);\n      config.SessionExpiredUrl   = \"/logout\";\n      config.SessionNotFoundUrl  = \"/\";\n  });\n  ```\n  Where:\n  - `config.TimeDelay` is the time it will take for a session to expire from when it is initialized within the application.\n  - `config.SessionExpiredUrl` is the URL of the application to which it will redirect when the session has expired.\n  - `config.SessionNotFoundUrl` is the URL of the application to which it will redirect when the application does not find the session key.\n\n3. Add this line in your page:\n  ```csharp\n  @inject ISessionProvider SESS\n  ```\n\nMake sure to put the render mode in \"InteractiveServer\" on each page you want to manage your servers.\n```csharp\n@rendermode InteractiveServer\n```\n\n## Quick Usage\n\n1. To store a session, add this line in your page/component:\n  ```csharp\n  SESS.CreateNewSession(new KeyValuePair(\"Key\", Value));\n  ```\n  You can use the same line to replace the value for \"Key\" session.\n\n2. To get it, use this line in your page/component:\n  ```csharp\n  var mySession = await SESS.GetSession\u003cobject\u003e(\"Key\");\n  ```\n  If you want to delete the key, just add `true` in the `removeIt` property:\n  ```csharp\n  var mySession = await SESS.GetSession\u003cobject\u003e(\"Key\", true);\n  ```\n  Or, if you just want to check if exists\n  ```csharp\n  if (await SESS.ExistKeyInSession(\"key\"))\n  {\n    // Stuff here...\n  }\n  ```\n\n3. If you want to delete the actual session manually, use:\n  ```csharp\n  SESS.RemoveSession();\n  ```\n  This will NOT delete all the sessions stored in the application.\n\nYou can't manage sessions in the method `OnInitialized` or `OnInitializedAsync`, because BlazorSessionProvider use (by default) JavaScriptInterop to get the key session in the browser.\n\n```csharp\nprotected override async Task OnInitializedAsync()\n{\n\tstring errorSess = await SESS.GetSession\u003cstring\u003e(\"your_session_name\");\n}\n\n/*\n\tThis will throw the next exception:\n\tInvalidOperationException: JavaScript interop calls cannot be issued at this time...\n*/\n```\n\nManage your sessions inside (or after) `OnAfterRender` or `OnAfterRenderAsync` to avoid this error\n\n```csharp\nprotected override async Task OnAfterRenderAsync(bool firstRender)\n{\n\t...\n\tstring goodSess = await SESS.GetSession\u003cstring\u003e(\"your_session_name\");\n\t...\n}\n```\n## Docs\nFor more information, see the [Wikia](https://github.com/oscardsoto/BlazorSessionProvider/wiki).\n***\nThank you so much for using BlazorSessionProvider.\n\nMade with ❤️ by Oscar D. Soto","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscardsoto%2Fblazorsessionprovider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foscardsoto%2Fblazorsessionprovider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscardsoto%2Fblazorsessionprovider/lists"}