Questions about the Asp.net session mechanism and conjecture

Source: Internet
Author: User
I am playing a website on my own these days, but I have encountered a session issue. I use the prototype Ajax object to access the page to obtain the parameter. This parameter must be determined based on the unique ID of the current session. Generally, this kind of requirement will come up with sessionid, so I used it. However, I was surprised to find that the sessionid changed every time I used Ajax for a request!
This is depressing... isn't it a problem with Ajax? After thinking about it, this possibility is exhausted. Cause: Asp.net cannot distinguish whether an HTTP packet is an asynchronous object from an xmlrequest or a general request from a browser. Asp.net only obtains an HTTP packet and does not mark whether the packet content is an asynchronous request. Later, I did a test and it also showed that the sessionid will change when the general request get or post is used. Okay, maybe my thinking is wrong. Change it. Because my client does not disable cookies, I want to start with cookies.
If the session of Asp.net is not configured as cookieless = true, a cookie of sessionid will be stored on the client,
Similar.

But the strange thing is: I didn't track this cookie. Why ??? What can't you do? Remember that all the articles mentioned that the session tag is maintained by the client cookie. After Asp.net finds the cookie in the HTTP header, you can find the corresponding data in the process.
Why am I absent? I asked some friends and shook my head. Some people even said that I had a problem with IE or that there was a problem with RP .... A lot of detours were taken to solve the problem during this period ..... later, in a casual code writing, every time I access the page, I saved the sessionid to the session as a key value, and then immediately retrieved it and returned it to the client. Sessionid remains unchanged this time! Later, I found that as long as you have performed operations on the session object or even executed the session. Clear () method, sessionid will not change! All requests sent in the same process on the client will be a sessionid !!! At this time, I realized that Asp.net's session mechanism is: if you do not operate or access session objects, will the request interfere with Session-related objects, the other advantage is that it saves a lot of server resources and does not require session-related initialization every time (it refers to retrieving the sessionid in the cookie, then construct the session object related to the current session for later use by the httpmodule .)
of course, this is also my own perceptual knowledge of the Asp.net session mechanism. There is no authoritative information indicating that the Asp.net session mechanism is like this. You are welcome to discuss it and correct it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.