如何获取属于特定会话的进程?
我想获取针对特定会话的所有进程。 即,如果有两个人正在使用我的 Web 应用程序,那么我想获取 user1 使用的所有进程和 user2 使用的所有进程。
I can get all processes by writing Process.GetProcesses() but how to get it in a group.
e.g:
User1: Process342
User1: Process151
User2: Process452
User2: Process674
User2: Process111
任何人都可以帮忙吗?
I want to get all the processes that is meant for a particular session.
i.e if there are two persons who are using my web application then i want to get all the processes used by user1 and all the processes used by user2.
I can get all processes by writing Process.GetProcesses() but how to get it in a group.
e.g:
User1: Process342
User1: Process151
User2: Process452
User2: Process674
User2: Process111
Can anyone please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我看到两种简单的方法可以在 C# 中执行您想要的操作(不了解 ASP.NET):
您可以按 SessionId 过滤进程以使进程为单个会话运行
或者您可以对结果进行排序以按会话对它们进行分组
I see two simple ways to do what you want in C# (don't know about ASP.NET):
You could filter the Processes by SessionId to get the processes running for a single session
Or you could sort the results to group them by session
您需要了解 ASP.NET 和 ASP.NET 是如何实现的。 IIS 协同工作 - 这些文章可能会有所帮助:
现在回到您的具体问题,ASP.NET 运行时托管在 IIS 工作进程中。 Session 只是一个从浏览器识别用户会话的逻辑范围,ASP.NET 提供了一个状态包来存储会话特定值。所有用户(会话)都由相同(一组)工作进程提供服务 - 因此查找每个会话的进程没有任何意义。您所能做的就是找出 Web 服务器上执行的进程。
You need to understand how ASP.NET & IIS works together - these articles may help:
Now coming to your specific question, ASP.NET runtime gets hosted in IIS worker process. Session is just a logical scope to identify user session from browser and ASP.NET provides a state bag to store session specific values. All users (sessions) get served by same (set of) worker process(es) - so finding processes per session does not make any sense. All you can do is to find out processes executing on the web server.