简体   繁体   中英

ASP.NET Session object & web farm

When the application is served from a web farm, a Session object CANNOT be used. Is that true?

No, you can use SQL-based sessions which can then in theory be accessed by any server in the web farm, with the correct configuration.

For a little more information : Configure SQL Server to Store ASP.NET Session State

Not so much cannot.

It depends on what you use & how you use it. If you're using sticky load balancer & it's configured as such, then each subsequent request from a user will always hit the same member node in the farm, in which case session use is ok.

If you have no such load-balancer or it's configured so that any request can be handled by any node, then you need to either use a 3rd party state service, such as asp.net provides, or disable the session. a 3rd party or out-of-process session service has certain restrictions on how you use it however, so if you go down that route, you'll need to research & test any solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM