Web应用程序中的登录问题 [英] login issue in web application

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

问题描述



在我的应用程序中,当用户登录应用程序时我更新数据库中的login_status =''Y''

如果用户闲置更多20分钟它将自动重定向到登录页面

如何更新数据库Login_status =''N''

解决方案

它可能会得到帮助会话状态管理



 <   configuration  >  
< system.web >
< sessionstate mode = InProc 超时 = 20 regenerateexpiredsessionid = true / >
< / system.web >
< / configuration >





然后如果在您的网络应用程序中存在Global.asax,在taht模块中

声明方法

  void  Session_End( object  sender,EventArgs e)
{
// 执行你的数据库逻辑他re !!!
}


可能取决于会员提供者 [ ^ ]您正在使用。但首先,使用会话!我们假设你这样做。比设置会话超时 [ ^ ]为相同的值 - 默认为20分钟,因此您可能不需要设置任何内容。

现在,您可以截取会话代码中的超时事件:在中实现一个Session_End处理程序global.asax

请参阅:http://www.techrepublic.com/article/working-with-the-aspnet-globalasax-file/5771721 [<一个href =http://www.techrepublic.com/article/working-with-the-aspnet-globalasax-file/5771721\"target =_ blanktitle =New Window> ^ ]



如果您使用的是asp.net 2.0,请阅读以下内容:

会话开始后,ASP.NET会话结束事件立即触发 - 已解决 [ ^ 之后立即触发

http://blogs.msdn.com/b/nikhiln/archive/2007/ 06/21 / detected-session-timeout-in-asp-net-2-0-web-applications.aspx [ ^ ]

编写代码,在登录页面的页面加载时将用户的登录状态更新为N


Hi,
In My application,when a user login into application i update the login_status=''Y'' in database
If the user idle for more 20 minutes it will automatically redirect to login page
How to update database Login_status=''N''

解决方案

It could be achived with help of Session state management

<configuration>
<system.web>
 <sessionstate mode="InProc" timeout="20" regenerateexpiredsessionid="true" />
</system.web>
</configuration>



then if in your web app exists Global.asax , in taht module
declare method

 void Session_End(object sender, EventArgs e)
{
//perform your DB logic here!!!
}


It might depend on what membership provider[^] you are using. But first of all, use sessions! Let''s suppose you do. Than set the session timeout[^] to the same value - by default it is 20 minutes, thus you will probably not need to set anything.
Now, you can intercept the session timeout event in code: implement a Session_End handler in global.asax
See: http://www.techrepublic.com/article/working-with-the-aspnet-globalasax-file/5771721[^]

If you are using asp.net 2.0 read these also:
ASP.NET Session End Event Fires Immediately After Session Start - Resolved[^]
http://blogs.msdn.com/b/nikhiln/archive/2007/06/21/detecting-session-timeout-in-asp-net-2-0-web-applications.aspx[^]


write the code to update login status of user to N at the page load of login page


这篇关于Web应用程序中的登录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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