has been using the session, the session lock does not have much attention, may be usually not noticed. Some time ago suddenly found that an AJAX GET request, direct access to the address, only dozens of MS, but loaded in the page, but requires 2s. Finally, the problem of locating the session.
Specific content I saw someone else's article in the garden: http://blog.csdn.net/paolei/article/details/38052129
However, some problems have also been identified.
For example, this example:
Back end:
public class Mycontroller:controller { //get:my public actionresult Index () { return View (); } [HttpGet] public string GetTest1 () { thread.sleep (+); return "GetTest1"; } [HttpGet] public string GetTest2 () { return ' GetTest2 '; } }
Front:
function (resp) { // server response }); $.get (function (resp) { // server response });
Direct use of the above code, no access to the session, the code by default does not perform session lock, running results:
GetTest2
GetTest1
After writing the session in the controller:
Public actionresult Index () { session["a", "a"; return View (); }
Operation Result:
GetTest1
GetTest2
Then press above before controller add: [SessionState (System.Web.SessionState.SessionStateBehavior.ReadOnly)], run again, found the result is the same, The description readonly is invalid.
In fact, although it is readonly, but the code is still written, this and ReadOnly is obviously contradictory, but the code will not error, but this property is invalid.
Later, changed to: [SessionState (System.Web.SessionState.SessionStateBehavior.Disabled)]
At this time to run again, the direct error.
Finally summed up, as long as the controller in the session of the write, no matter what the controller before the Sessionstatebehavior, will think the session is writable, session lock will be performed. Therefore, if the Ajax concurrency performance requirements are relatively high, you can not use the session. So, think sessionstatebehavior this attribute a little chicken ah. My humble opinion, if have a master hope pointing twos.
Later, I think of their own application is not a way to put another Ajax load slower, using timeout 20ms, this is called a complex computation to load to-do number, and the other is to load the page list data, it is obvious that users initially want to see the list of data first.
Problem with ASP. NET MVC Session Lock