簡體   English   中英

如何在 ASP.net 核心 3.1 中創建新的 session id?

[英]How to create a new session id in ASP.net core 3.1?

我使用下面的代碼在 Asp.net 中創建了 session id。

var sessionManager = new  SessionIDManager();
var sessionId = sessionManager.CreateSessionID(HttpContext.Current);

有人可以建議如何在 asp.net 核心 3.1 中執行相同的功能嗎?

為什么需要 Session ID? 如您所知, SessionIDManager是一個 ASP.Net 全框架 class,因此它不可用,因此可能有更新更好的方法。

Just beware in ASP.NET core 2.1 that every request.. the session ID changes.. (HttpContex.Session.Id): here is the fix for that, read all 3 top answers: ASP.NET core 2.1 session

這是一個解決方案,go 提前並使用 session 自己設置一個 SessionID:

Session.SetString("SessID", new Guid().ToString());

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM