gpt4 book ai didi

asp.net - 应用程序状态变量在网络场服务器中工作正常吗

转载 作者:行者123 更新时间:2023-12-02 21:32:34 25 4
gpt4 key购买 nike

我正在使用应用程序变量来存储值并再次访问它。但是我的问题是因为我们使用多个服务器(网络场)。当我们继续使用多个服务器时,访问值时是否会出现任何问题,或者不值得将值存储在应用程序状态变量中

谢谢王子

最佳答案

不,根据documentation,应用程序状态不会在网络场中的服务器之间共享。 (请参阅标题为可扩展性的部分)。

Application state is not shared among multiple servers serving the same application, as in a Web farm, or among multiple worker processes serving the same application on the same server, as in a Web garden. Your application therefore cannot rely on application state containing the same data for application state across different servers or processes.

您需要找到其他存储此共享信息的方式,即通过数据库或共享缓存。

但是,您将能够在网络场中的所有服务器之间共享 View 状态和表单例份验证票证,但您必须设置 <machineKey>在所有服务器上设置相同的值。

来自下面的第一篇文章:

If you deploy your application in a Web farm, you must ensure that the configuration files on each server share the same value for validationKey and decryptionKey, which are used for hashing and decryption respectively. This is required because you cannot guarantee which server will handle successive requests.

这些 MSDN 文章提供了更多信息:
http://msdn.microsoft.com/en-us/library/ff649308.aspx#paght000007_webfarmdeploymentconsiderations
http://msdn.microsoft.com/en-us/library/eb0zx8fc.aspx

关于asp.net - 应用程序状态变量在网络场服务器中工作正常吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9552067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com