Session usage and principles in asp + () can also be used without cookie

Source: Internet
Author: User

/*
Tofu is made of excellent products
Http://www.asp888.net bean curd technology station
Retain the copyright information if reprinted.
*/
Session management, our traditional asp program is actually a session connection of dead, the system is actually in our client book
Write a Cookie. When we set the Cookie in the security settings of our browser to Prompt, when we access
When there is a Session page, a prompt is displayed indicating whether to allow cookies. When we set it to not allow cookies, we
The Session is always unsuccessful. For example:

<%
Session ("username") = "Tofu"
Session ("URL") = "http://www.asp888.net"
%>

In the ASp. Net environment, the Session is completely redefined, because the current ASp. Net environment of tofu is in the PDC version,
Therefore, there is no Demo for the Beta1 version. If Beta1 content is involved here, it is only described in materials and has not been passed through
Bean curd Test

In fact, for some comrades who do not want to study it, tofu said: in fact, the use of asp.net is the same as that of asp, and even
It is simpler because, based on the observation of bean curd, we do not need to continue to consider the status of the cookie option on the client, because
The session can be smoothly transmitted regardless of the client settings.

Next we will give a brief and in-depth understanding of the asp.net session mechanism. Due to the limited technology, I am not very clear about some problems,
So you are welcome to discuss this article together.

In the PDC version, open the % systemroot % complus (version) config. web file and find sessionstate.
You can see the previous content:
<Sessionstate
Inproc = "true"
Usesqlserver = "false"
Cookieless = "false"
Timeout = "20"
Server = "localhost"
Port = "42424"
/>

When inproc is True, asp.net will adopt a mechanism called in-process to save Session data on this server,
If both inproc and usesqlserver are false, an out process mechanism is adopted to store sessions in a dedicated
Save the session on the server, this will solve the session sharing when accessing different hosts of a site, this previously in asp
It is absolutely impossible.
In the Beta1 version, config. web has changed a lot. Let's take a simple look:
<! -- Sessionstate attributes:
Mode = "inproc" | "sqlserver" | "stateserver"
Cookieless = "true" | "false"
Timeout = <session timeout in minutes, a whole number greater than 0>
Sqlconnectionstring = <acceptable values for SQLConnection. ConnectionString,
Only used when mode = "sqlserver">
Server = <server name, only used when mode = "stateserver">
Port = <port number, only used when mode = "stateserver">
-->
Let's talk about the session section of the config. web file. Let's take a look at the cookieless problem:
This Cookieless is not what we usually understand whether to save cookies on the client. According to bean curd observation, ASP.net session
No cookie is generated on the browser client.
When we set cookieless to false, let's take a look at this program.
<% @ Page Language = "VB" %>
<% Session ("name") = "Tofu" %>
<% = Session ("name") %>
After the program is executed, we do not receive any prompts from the browser, although we also use the Session
When we set cookieless to true and run this program again, we find that the program is still
Correct execution, but the address bar of the browser has changed. We used
Http: // host/testsession. aspx is now changed to http: // host/(contains many strings)/testsession. aspx
It is estimated that this session does not even generate a Cookie on the server. Therefore, this session has to be used (including many strings ).
Content to save the Session content

When both inproc and usesqlserver are set to false, it indicates that we will use out process.
Server name. This server is the server that agrees to save the session. We need to start the asp state service on this server.

When we need to use SQL server, we must enter the connection string of SQL server, so that the session will be saved
A database of SQL server. Of course, this database is generated. However, in the PDC version, I did not find the installation file for this database.
So I can't do anything about this part of SQL server. If I'm not happy with it, I installed a PDC version. Now I regret it :(

Through these studies, do we have a better understanding of the asp.net session mechanism?


Author: tofu (original)


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.