'Session' does not exist in the current context. How can I use it?

dimauser

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.

dpberry178

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";

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

"The name 'n' does not exist in the current context". How can I reference a type outside of its context?

The name 'i' does not exist in the current context

@ViewBag does not exist on current context

The name 'ModelState' does not exist in the current context

The name 'zipfile' does not exist in the current context

The name "SqlServerValueGenerationStrategy" does not exist in the current context

Name 'of table' does not exist in the current context

The name Display Alert does not exist in the current context?

The name 'SqlDataSourceEnumerator' does not exist in the current context

How to clear all textboxes in a Web Form? (The name 'form1' does not exist in the current context)

Xamarin Forms "...DisplayAlert does not exist in the current context."

Error CS0103: The name 'InitializeComponent' does not exist in the current context

The name does not exist in the current context when using an if statement

The name 'Console' does not exist in the current context In xamarin forms app

Unity WebGL build error: The name Network does not exist in the current context

RazorEngine throws 'the name model does not exist in the current context' at runtime

CS0103 - The name 'GetListFromCVS' does not exist in the current context

How does @Transactional influence current session in Hibernate?

How can i use a session for both clojure/script

How can I use *ngFor current object outside of the ngFor?

How can I link the current time in the audio context to input type=range?

How can I kill the current php artisan serve session before starting a new one?

Function call from aspx design time error "name does not exist in the current context"

ASP.NET MVC View: The name 'inject' does not exist in the current context

ASP.NET core web api "the name view does not exist in current context"

The name 'InitializeComponent' doesn't exist in the current context

The name Request doesnt exist in current context

How can I test that a key does NOT exist at different levels of a multidimensional array using data providers?

StateError (Bad state: field does not exist within the DocumentSnapshotPlatform). How can I get a doc from firestore?

TOP lista

quentelabel

Arquivo