1

I have used below code to create session id in Asp.net.

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

Can somebody suggest how to do same functionality in asp.net core 3.1???

jps
  • 20,041
  • 15
  • 75
  • 79
Nalini Chava
  • 11
  • 1
  • 2

1 Answers1

1

Why do you need the Session ID? As you know SessionIDManager is a ASP.Net full-framework class, so its not available, hence there is probably a newer & better way.

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

Here's a solution, go ahead and set a SessionID yourself using the session:

Session.SetString("SessID", new Guid().ToString());
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321