在Visual Studio 2013会话管理? [英] Session management in Visual Studio 2013?

查看:130
本文介绍了在Visual Studio 2013会话管理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net进出口新的开发。我想打一个会话管理,如果10分钟而采取任何行动的推移,系统将结束会话,并注销用户。

Im new developer in asp.net. I want to make a Session management that if 10 minutes passes without any action, the system will end the session and logout the user.

我搜索一下,我发现这个code:

I searched about it and I found this code:

在Web.config文件中:

In Web.config file:

<sessionState
   mode="InProc"
   cookieless="true"
   timeout="10" />

而在页面中,我们要结束会话:

And in the page we want to end the session:

public int Timeout { get; set; }

但是,当我试了一下,没有工作!
我不知道我应该尝试在一台服务器,而不是本地主机或本code不能满足我需要的目的是什么?

But when I tried it, it didn't work! I don't not know should I try it in a server rather than localhost or this code does not satisfy the purpose that I need ?

推荐答案

尝试

public class PageBase : System.Web.UI.Page

{

protected override void OnPreRender(EventArgs e)

{

base.OnPreRender(e);

AutoRedirect();

}

public void AutoRedirect()

{

int int_MilliSecondsTimeOut = (this.Session.Timeout * 60000);

string str_Script = @"

<script type='text/javascript'>

intervalset = window.setInterval('Redirect()'," + int_MilliSecondsTimeOut.ToString() + @");

function Redirect()

{

alert('Your session has been expired and system redirects to login page now.!\n\n');

window.location.href='/login.aspx';

}

</script>";

ClientScript.RegisterClientScriptBlock(this.GetType(), "Redirect", str_Script);

}

}

阅读更多<一个href=\"http://www.dotnetgallery.com/kb/resource9-how-to-do-auto-logout-and-redirect-to-login-page-when-session-expires-using.aspx\"相对=nofollow>如何做自动退出并重定向会话时使用asp.net到期登陆页面?

自动重定向到登录页面时,会议已过期

这篇关于在Visual Studio 2013会话管理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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