简体   繁体   English

与Web服务共享Web应用程序会话

[英]Sharing web application session with a web service

Environment: 环境:

We are having a Website and a separate ASMX - Web Service sharing the same database (MS SQL 2008). 我们有一个网站和一个单独的ASMX - Web服务共享同一个数据库(MS SQL 2008)。 Web Service is serving the Mobile Apps at the moment. Web Service目前正在为移动应用程序提供服务。 Projects are done using c#, Asp.Net, 3.5 framework, VS 2008. 项目使用c#,Asp.Net,3.5框架,VS 2008完成。

Requirement: 需求:

We need to avoid same user login into Website and Mobile App (Using the Web Service) at the same time. 我们需要避免同一用户同时登录网站和移动应用程序(使用Web服务)。 Basically user can log in only to a one service at a time (either web or app). 基本上,用户一次只能登录一个服务(Web或应用程序)。 Also, user should be able to log in to Mobile App as soon as web browser is closed or logged out. 此外,用户应该能够在Web浏览器关闭或注销后立即登录移动应用程序。

If user tries to log in while already logged into the other service, code should have a way to find it for notification and restriction purposes. 如果用户在登录其他服务时尝试登录,则代码应该有办法找到它以用于通知和限制目的。

I think AppFabrc address the requirement but needs Windows Server 2008 R2 which we don't have at the moment. 我认为AppFabrc满足了这一要求,但需要我们目前还没有的Windows Server 2008 R2。

Hope you have better ideas?? 希望你有更好的想法?

Please note this is not the same question as this . 请注意,这是不一样的问题,

FYI... you don't get any notification when the browser closes. 仅供参考......浏览器关闭时,您不会收到任何通知。 You could go based on the last activity time (basically keep track of user activity - page clicks, etc). 您可以根据上次活动时间(基本上跟踪用户活动 - 页面点击等)。 I also don't see how appFabric is going to help. 我也看不到appFabric将如何提供帮助。 You still have the same problem. 你仍然有同样的问题。

As others have mentioned, there is no easy way to know when somebody has closed the browser. 正如其他人所提到的,没有简单的方法可以知道某人何时关闭了浏览器。 You could use javascript to detect when somebody leaves your web app but there are some issues (see the following question and answers for more information: How to capture the browser window close event? ) 您可以使用javascript来检测某人何时离开您的网络应用程序但有一些问题(有关更多信息,请参阅以下问题和答案: 如何捕获浏览器窗口关闭事件?

If you're open to other workflows, you could try this: 如果您对其他工作流程开放,可以尝试这样做:

  • When the user logins to the mobile app, have the mobile app log him out from the web site. 当用户登录移动应用程序时,让移动应用程序将他从网站上注销。
  • When the user logins to the web site, have the web site log him out from the mobile app. 当用户登录网站时,让网站将他从移动应用程序中注销。

That way your users would login and start working right away instead of them having to log in, see an error, logout from the other app, log in again. 这样您的用户就可以登录并立即开始工作,而不必登录,查看错误,从其他应用程序注销,再次登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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