如何在Asp .net中跨模块维护会话 [英] How to maintain session across modules in Asp .net

查看:69
本文介绍了如何在Asp .net中跨模块维护会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我是Asp .net的新手。

我只是想知道如何维护模块间的会话。





问候

Froxy

Hi
I am new to Asp .net.
I just want to know how to maintain the session across the modules.


Regards
Froxy

推荐答案

简单地说,所有您需要做的是使用Session对象来维护会话。然后,只要用户保持在同一会话中,您的用户就会看到相同的值。但是,当事情变得更加复杂时,就是当您开始考虑是否使用单个服务器来托管Web应用程序或Web场/花园时。如果您可以跨多个服务器为同一个用户提供服务,那么注册会话功能的方式就会发生变化。



在一台机器上,可以合理地期望你会将会话存储设置为InProc(您可能希望将其设置为单独的会话进程运行,在这种情况下,您可以将其设置为以StateServer运行)。如果您的应用程序在Web场/园中运行,那么您需要考虑使用存储在SqlServer中的会话状态。



在Web场场景中,您需要确保您的计算机都使用相同的MachineKey,并且IIS Metabase中所有服务器上的应用程序路径应该完全相同。
Simplistically, all you need to do is use the Session object to maintain session. Then, your user will see the same values present in there as long as they remain in the same session. Where things get more complicated, however, is when you start to consider whether or not you are using a single server to host the web application, or a web farm/garden. If you can serve the same user across multiple servers, then the way that you register the Session functionality changes.

On a single machine, it's reasonable to expect that you will set your session storage to InProc (you may want to set it to run as a separate session process, in which case you would set it to run as StateServer). If your app is running on a web farm/garden, then you need to be looking into using session state stored in SqlServer.

In the web farm scenario, you need to ensure that your machines all use the same MachineKey, and the application path in IIS Metabase across all the servers should be exactly the same.


这篇关于如何在Asp .net中跨模块维护会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆