如何在ASPX网站上只允许一个用户? (C#) [英] How to allow only ONE user on an ASPX web site? (C#)

查看:71
本文介绍了如何在ASPX网站上只允许一个用户? (C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我开发了一个.aspx网站。由于网站的性质

网站,只有一个用户可以同时使用此网站。我怎么

锁定第二个用户?应用程序[" ...]变量也许?


非常感谢您的帮助!

解决方案

静态变量在所有用户会话之间共享。如果你做了什么

喜欢

public static bool IsInUse;并且第一个用户将其设置为true,

其他用户会话将检测到它。


如何检测用户何时完成使用网站?


-

Eliyahu Goldin,

软件开发人员

Microsoft MVP [ASP。 NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

" S_K" < st *********** @ yahoo.com写了留言

新闻:11 ******************* ***@z24g2000prh.googlegr oups.com ...





我开发了.aspx网站。由于网站的性质

网站,只有一个用户可以同时使用此网站。我怎么

锁定第二个用户?应用程序[" ...]变量也许?


非常感谢您的帮助!



" S_K" < st *********** @ yahoo.com写了留言

新闻:11 ******************* ***@z24g2000prh.googlegr oups.com ...


我开发了一个.aspx网站。由于网站的性质

网站,只有一个用户可以同时使用此网站。我怎么

锁定第二个用户?申请[" ...]变量也许?



只有当你完全可以100%信任你的用户通过你提供的手段

注销时才可以重置应用程序变量...


ASP.NET没有可靠的方法来了解用户是否已经离开了您的网站,或者关闭了他们的浏览器等......

-

Mark Rae

ASP.NET MVP
http://www.markrae.net


" Eliyahu Goldin < RE ************************** @ mMvVpPsS.org写在

消息新闻:eY **** ********** @ TK2MSFTNGP06.phx.gbl ...


您将如何检测用户何时完成网站使用?



这就是问题...

-

Mark Rae

ASP.NET MVP
http://www.markrae.net


Hi,

I have an .aspx website developed. Because of the nature of the web
site only one user can be using this site at the same time. How do I
lock out the second user? Application["...] variable perhaps?

Thanks so much for you help!

解决方案

Static variables are shared between all user sessions. If you make something
like
public static bool IsInUse; and the first users will set it to true, the
other user sessions will detect it.

How are you going to detect when the user completes using the site?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"S_K" <st***********@yahoo.comwrote in message
news:11**********************@z24g2000prh.googlegr oups.com...

Hi,

I have an .aspx website developed. Because of the nature of the web
site only one user can be using this site at the same time. How do I
lock out the second user? Application["...] variable perhaps?

Thanks so much for you help!



"S_K" <st***********@yahoo.comwrote in message
news:11**********************@z24g2000prh.googlegr oups.com...

I have an .aspx website developed. Because of the nature of the web
site only one user can be using this site at the same time. How do I
lock out the second user? Application["...] variable perhaps?

Only if you can absolutely 100% trust your user(s) to log out via a means
that you provide so that you can reset the Application variable...

ASP.NET has no reliable way of knowing if a user has navigated away from
your site, or closed their browser etc...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:eY**************@TK2MSFTNGP06.phx.gbl...

How are you going to detect when the user completes using the site?

That''s the problem...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


这篇关于如何在ASPX网站上只允许一个用户? (C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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