i got a problem in using Session. I was following many tutorials and documentations on different sites but still can't figure out how to use Session in my context.
So basically I want to use users login name during the whole session. I've read Session is the thing I need.
Did i forget to import something? Am I using it wrong?
https://i.stack.imgur.com/vwTMb.png
Can someone please help me with that?
Thank you very much in advance for your answer.
For .NET Core try:
using Microsoft.AspNetCore.Http;
then
HttpContext.Session.SetString("test key", "test value");
For .NET framework (pre .NET 5) try:
HttpContext context = HttpContext.Current;
context.Session["Test key"] = "Test value";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.