MiniWebServer.Session 0.3.3

dotnet add package MiniWebServer.Session --version 0.3.3
NuGet\Install-Package MiniWebServer.Session -Version 0.3.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MiniWebServer.Session" Version="0.3.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MiniWebServer.Session --version 0.3.3
#r "nuget: MiniWebServer.Session, 0.3.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MiniWebServer.Session as a Cake Addin
#addin nuget:?package=MiniWebServer.Session&version=0.3.3

// Install MiniWebServer.Session as a Cake Tool
#tool nuget:?package=MiniWebServer.Session&version=0.3.3

Session là gì?

HTTP vốn là một giao thức stateless, tức là mỗi lần gửi request hoàn toàn độc lập với nhau, HTTP được thiết kế như vậy bởi ban đầu nó được dùng để phục vụ nội dung tĩnh, các web server hoàn toàn không hỗ trợ việc chạy các chương trình trên server, cũng như không hỗ trợ tạo ra nội dung động. Tư tưởng thiết kế này vẫn giữ nguyên trong những phiên bản HTTP sau này, phần vì phải giữ tính tương thích, phần vì việc giữ giao thức này là staless giúp cho việc phân phối các request dễ dàng hơn khi triển khai các web farm, trong đó nhiều server cùng phục vụ nội dung cho một web site. Tuy nhiên khi chạy chương trình, người ta vẫn có nhu cầu lưu lại trạng thái giữa các lần gọi, hay còn gọi là stateful, các request này cần được chia sẻ trạng thái với nhau, và ta gọi chúng là thuộc cùng một session. Hai request khác nhau nhưng thuộc cùng session thì có thể chia sẻ trạng thái cho nhau. Để làm điều này, người ta tạo ra một khái niệm mới: Cookie. Cookie là một chuỗi được đặt tên, sẽ được gửi lên cùng với request và gửi về cùng response. Thông thường HTTP server sẽ không quan tâm đến nội dung của cookie, nhiệm vụ của nó chỉ là mỗi khi nhận được một cookie trong request, nó sẽ gửi lại cookie đó trong response, các trình duyệt cũng tương tự, khi nhận về một cookie từ response, nó sẽ gửi lên cùng request tiếp theo. Một cookie với tên quy ước trước sẽ được dùng để chứa một khóa gọi là Session Id, vì các cookie được gửi và nhận giữa các request/response trong cùng một session nên chúng có cùng một giá trị của Session Id. HTTP server sẽ lấy giá trị của cookie này, dùng nó làm khóa và tìm trong một bảng, ta tạm gọi là session dictionary, mỗi một bản ghi trong dictionary này lại là một dictionary nữa, chứa các cặp key/value. Ta sẽ gửi dictionary con này vào trong context (IMiniAppContext trong Mini-Web-Server) và chuyển đến cho các middleware, HTTP server hoàn toàn không quan tâm việc dictionary này làm gì (separation of concerns, chúng ta áp dụng khái niệm này rất nhiều trong Mini-Web-Server), các middleware có thể chỉnh sửa lại dữ liệu trong dictionary trong lúc chúng xử lý, mà không cần gửi về giá trị lại cho client, việc này do HTTP đảm trách (một lần nữa, ta lại áp dụng separation of concerns).

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.3 205 11/17/2023
0.3.2 95 11/14/2023
0.3.1 80 11/9/2023
0.3.0 76 11/9/2023