asp.net Intranet应用程序中的会话超时问题 [英] Session Timeout Problem in asp.net Intranet Application
问题描述
亲爱的朋友们,
我遇到会话超时问题。
我创建了一个网络在asp.net中使用C#和数据库作为Sql2005。它的工作正常。
当应用程序空闲时,它会显示会话错误。
这个应用程序,第一页是登录页面。
它显示错误
lbluser.Text = Session [UserName]。ToString();
此代码在母版页中。这用于显示带有标签的用户名
例如
欢迎开发先生
但是当程序空闲时,当我点击此应用程序中的某些链接时,它会显示会话错误。
请帮忙我,怎么解决。
先谢谢。
请检查会话是否存在on pageload
if (会话[ UserName] == )
{
Response.redirect( Loginpage.aspx 跨度>);
}
谢谢
检查这个
http://forums.asp.net/t/1283350.aspx [ ^ ]
HI,
您可以在页面加载中查看会话,然后执行操作:
< pre lang =cs> if (!string.IsNullOrEmpty(Convert.ToString(Session [ < span class =code-string> UserName])))
{
// 重定向到相应的页面
}
else
{
// 重定向到登录页面
}
这里IsNullOrEmpty同时检查空值和值。
还有另一种方式:
增加会话超时值。
1.Session.Timeout = 540;
2.< system.web>
.......
< sessionstate timeout = 1440 > < / sessionstate >
< / system.web >
谢谢
Dear Friends,
am facing problem with session timeout.
I have created a web application in asp.net with C# and database as Sql2005. its works fine.
When the application is idle, it shows the session error.
for this application, first page is login page.
it shows the errror
lbluser.Text = Session["UserName"].ToString();
This code is in master page. this is used for displaying username with label
for example
Welcome Mr. Developer
but when the progam is idle , when i click some links in this application it shows Session Error.
Please help me, how to solve.
Thanks in Advance.
Please check the session exists or not on pageload
if(Session["UserName"]=="") { Response.redirect("Loginpage.aspx"); }
Thanks
check this
http://forums.asp.net/t/1283350.aspx[^]
HI,
You can check the session existance in the pageload and then perform your operations:
if (!string.IsNullOrEmpty(Convert.ToString(Session["UserName"]))) { //Redirect to the respective page } else { //Redirect to the login page }
Here IsNullOrEmpty checks for the null as well as "" values simultaneously.
There is another way:
Increase the session timeout value.
1.Session.Timeout = 540;
OR
2.<system.web> ....... <sessionstate timeout="1440"></sessionstate> </system.web>
Thanks
这篇关于asp.net Intranet应用程序中的会话超时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!