The asp.net variable is set even if EnableSessionState = "ReadOnly"

I have a page with the directive EnableSessionState = "ReadOnly" .

When I have:

this.Session.Add("MyVar","TempVar"); 

The following query returns NULL .

When I have:

 this.Session["MyVar"] = "TempVar"; 

the following query returns "TempVar"

can this behavior be disabled?

+4
source share
1 answer

The reason this happens is because Session [""] accesses the array using get; set; accessory, which, obviously, is not installed to check the status of allowessionstate. Thus, basically its receipt is placed in this array, but it is not saved. Unlike the .Add () function, which will explicitly test it. This is likely to reduce get overhead; set; properties.

As someone else said, you can see it for the same request, but don’t save it in the session.

0
source

All Articles