检查用户是否已经在asp.net中登录Web应用程序 [英] To check if a user already login in a web application in asp.net

查看:285
本文介绍了检查用户是否已经在asp.net中登录Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在asp.net中有一个Web应用程序,因为我已经从数据库中检查了用户的用户名和密码,并重定向到了指定的页面.现在,如果同一用户将其凭据通过登录页面,则它应表明您已经登录.

请让我知道如何处理它.有没有一种方法可以完成它,因为我们知道在大多数网站(例如gmail等)中,用户可以一次在不同的浏览器或相同的浏览器中使用相同的凭据登录.如果用户已登录,则如果他再次尝试登录,则应显示您已经登录.

谢谢你

Mohd Wasif

Hi All,

I have an web application in asp.net in that i have checked userid and password of a user from database and redirecting to a specified page. Now if same user passes it''s credential to login page then it should show that you are already login.

Please let me know how to handle it .Is there a way to accomplish it as we know that in most of websites (like gmail etc) the user can login with same credential at a time in different browser or same browser.So I want that if a user is login then if he tries again login then it should show that you are already login.

Thanking You

Mohd Wasif

推荐答案

如果您使用的是表单身份验证,请
If you are using Forms Authentication,
System.Web.HttpContext.Current.User.Identity.IsAuthenticated

>可以为您提供此信息.

can give you this information.


您可以通过两种方式实现.
服务器端缓存变量或使用哈希表或仅维护当前登录用户的任何对象作为应用程序变量.
或者,您可以在登录后将数据库中用户的活动状态设置为1,然后在再次登录之前参考该状态.
You can implement this in two ways.
Server side caching variable or as an application variable using hashtable or any object which just maintains the current loggin users.
Or you can set the active state of the user in database as 1 once logged and refer to that before logging again.


这篇关于检查用户是否已经在asp.net中登录Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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