管理会话状态

发布于 2024-07-11 12:25:54 字数 164 浏览 7 评论 0原文

我需要维护数据库中的会话状态。 但是我无法直接从网络服务器访问数据库。 Web 服务器与应用程序服务器通信,而应用程序服务器又可以访问数据库。
有没有办法配置这个? 或者是否必须编写自定义组件。
进行此设置的原因是为了实现负载平衡并允许用户会话从一台服务器重定向到另一台服务器。

I have a need to maintain the session state in the database. However I cannot access the database directly from the web server. The web server communicates with an app server which in turn has access to the database.

Is there a way to configure this? Or does a custom component have to be written.

The reason for this setup is to allow for load balancing and to allow the session of a user to be redirected from one server to another.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

北座城市 2024-07-18 12:25:54

使用 ASP.NET 会话状态服务,您可以直接在应用程序服务器上运行此服务 - 请参阅 MSDN 此处 - 并配置您的所有网络主机以将其用户会话状态存储在该中央状态服务器上。 ASP.NET 会话状态服务将会话存储在应用服务器的内存中,并且不需要 SQL Server 数据库。

Use the ASP.NET Session State service, You can run this service directly on your app server - see notes on MSDN here - and configure all your web hosts to store their user session state on that central state server. The ASP.NET Session State service stores sessions in memory on the app server, and doesn't require a SQL Server database.

夏末 2024-07-18 12:25:54

请注意,如果您认为因为使用多个 Web 服务器而需要在数据库中存储会话,则情况并非如此:您可以使用 StateServer。 这意味着您在一台计算机上启用会话状态服务,并在所有 Web 服务器的 web.config 中设置该计算机,以便它们都使用同一台计算机进行状态。

Note that if you think you need to store sessions in the database because you are using more than one web server, that is not the case: you can use StateServer. That means you enable the session state service on one machine and set up that machine in the web.config of all your web servers so that they all use the same machine for state.

青巷忧颜 2024-07-18 12:25:54

您唯一的选择是构建自定义组件。

它们实际上并不难做到,因为您唯一需要的就是浏览器从 cookie 或查询字符串向您发送一个值。 存储的只是名称值对。

请参阅 http://msdn.microsoft.com/en-us/library/aa479034 .aspx

Your only option is to build a custom component.

They really aren't that difficult to do as the only thing you need is for the browser to send you a value from either a cookie or the query string. What's stored is simply name value pairs.

see http://msdn.microsoft.com/en-us/library/aa479034.aspx

深爱成瘾 2024-07-18 12:25:54

您可以编写自定义 SessionState 提供程序..我认为这是唯一的方法..看看 MSDN 此处

You can write a custom SessionState provider.. I think it's the only way.. Have a look on MSDN here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文