This article is a mirror article of machine translation, please click here to jump to the original article.

View: 23971|Reply: 0

[Source] asp.net Customize the session id name

[Copy link]
Posted on 7/14/2019 7:46:59 PM | | |
Scenario 1: In the asp.net web application ASP.NET_SessionId a set of algorithms defined by Microsoft, a set of complex algorithms based on hardware IDs, can generally ensure non-duplication. However, if you want to ensure that there are no duplicates, you can define the SessionID generation method yourself. Portal:http://msdn.microsoft.com/zh-cn/ ... nidmanager.validate(v=vs.80).aspx

Scenario 2: In the asp.net web application, the Session session is automatically opened (can be closed in web.config), so that the website maintains the user's session state ASP.NET_SessionId regardless of whether the user has business needs or not! This creates performance consumption for no reason.

So in MVC3, Microsoft has removed this part of the performance consumption, and when the business uses the session, it is generated by the business logic!

SessionIDManager.Validate(String) Method

Gets a value that indicates whether the session identifier is valid or not.


example

The following code example shows the inherited class SessionID, the SessionIDManager class, and overrides the CreateSessionID and Validate method, providing and validating the method Guid as the SessionID.

To use the custom class demonstrated in this example, the SessionID will have a custom class in the Web.config file, as shown in the example below for the HTTP module.


manager esp manage custom virtual col var == quest

Create a new class called CustomSessionIDManager

Modify Web.Config







Previous:Python introductory tutorial full version (you can learn it if you know Chinese)
Next:Java kryo/protobuf/protostuff serialization or JSON performance comparison
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com