-1

In normal asp.net, we can get the value of this by giving:

UserSessionID = System.Web.HttpContext.Current.Session.SessionID;
IPAddress = System.Web.HttpContext.Current.Request.UserHostAddress;

How can we get the same in .Net Core. Can anyone help?

Lim
  • 25
  • 6

1 Answers1

1

Assuming your session is setup like this:

HttpContext.Session.SetString("mysession", "mySessionValue");

Then you can get the Session id:

UserSessionID = HttpContext.Session.Id;

And the user host address:

IPAddress = HttpContext.Connection.RemoteIpAddress;
Rahul Sharma
  • 6,339
  • 2
  • 23
  • 41