asp.net Session sharing problem may be encountered during development or deployment, how to share sessions between different applications? I looked for it today, there are many methods on the Internet, among which the use of SqlServer database sharing session is the most common, if you need to go to Baidu by yourself, it will come out. But wouldn't it be a big problem if the database was not SqlServer but something else like Oracle? Fortunately, today I found another way to implement Session sharing without using the database, that is, using the StateServer method. Without further ado, take a look at the implementation steps:
1. Open the registry, run cmd/regedit, and find node HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\aspnet_state\Parameters
a. Set the AllowRemoteConnection value to 1
[b. Set the Port value to a5b8 (hexadecimal), i.e. decimal 42424 (default)]
The above literally allows remote connection and setting ports
2. Change the startup type of the computer service "ASP.NET State Service" to Automatic, and start the service at the same time.
3. Add it under the system.web node in the web.config file of website project A and website project B, respectively
Remember to replace with the IP of the service and the port set in step 1
4. Add the following code to the Global.asax.cs of website project A and website project B respectively
Pay attention to twoAPPNAME should be set to the same。 The above solves the problem of Session sharing. The above solutions are referenced here
Finally, you can test that you can write Session in website project A to read in website project B, or write Seesion in website project B to read it in website project A.
|