asp.net应用程序中的会话超时 [英] session time out in asp.net application

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

问题描述

除了1.web.config(System.web),2.global.asax和3.IIS(ASP.NET - > state)之外,为asp.net应用程序设置会话超时值的可能方法是什么? mgmt - >编辑配置 - >会话超时。实际上我在维护和支持项目中工作。我们需要解决一个问题,即最终用户在提交详细信息时每2分钟就会超时。所以他要求我们将会话超时值增加到5分钟,但我们无法找到为该应用程序设置会话超时值的位置(会话超时不在web.config,global.asax和IIS服务器中20分钟)

任何帮助都将受到赞赏

What are the possible ways to set session time out value for asp.net application other than 1.web.config(System.web), 2.global.asax and 3.IIS(ASP.NET-->state mgmt-->edit configurations-->session timeout. Actually im working in a maintance and support project. We need to resolve one issue ie end user is getting timed out for every 2 mins when he is submitting details. So he requested us to increse session time out value to 5 mins, but we are unable to find where that session time out value is set for that application(session time out not there in web.config, global.asax and 20 mins in IIS Server)
Any help would be appreciated

推荐答案

您可以在页面中的任何事件内设置会话超时。

For例如,如果要为特定页面设置会话超时,则只需在该特定页面的Page_Load事件中写下以下代码:



You can set Session Timeout inside any Event in a Page.
For example if you want to set Session Timeout for a particular page, then simply write down the following Code inside Page_Load Event of that particular page:

protected void Page_Load(object sender, EventArgs e)
    {
        //Setting Session Timeout to 30 Mnts
        Session.Timeout = 1800;
    }





如果你想在用户点击特定按钮或任何控制时设置会话超时,你可以简单根据您的要求在任何控制事件中设置Session的Timeout属性。例如见下文。我在Button_Click事件中设置超时属性:





And if you want to set Session Timeout when user Clicks a particular Button or Any Control, the simple you can Set Timeout property of Session inside any Control Event as per your Requirement.For Example see below.I''m Setting timeout property inside Button_Click event:

protected void Button1_Click(object sender, EventArgs e)
    {
        //Setting Session Timeout to 30 Mnts
        Session.Timeout = 1800;
    }





希望它会帮助你。



Hope It''ll help you.


这篇关于asp.net应用程序中的会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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