请问各位大侠,我用asp.net做了一个网站,用cookie保存登陆信息。失效时间设为1天。但是现在十几分钟不对网页操作她就提示要重新登陆,请问这是怎么回事,改怎么把时间延长了呢?谢谢
解决方案 »
- 如何根据身份证,获取此人所在的省份
- |zyciis| javascript中的function传进来一个function的时候,如何判断他的第一个参数和改变他的第一个参数 谢谢 示示例
- 跳转问题>> Redirect() 跳转不到新网站,急
- 在ASP.NET MVC2 中导出excel
- 论一下:::做一个相册,图片文件是该放在数据库中,还是放在目录中
- 请教 孟子E章 javascript问题
- 求asp.net视频教程 急急急
- (最后十分了)asp.net修改数据时的问题,现在把数据读出来了,但不知道要怎么把数据显示在<asp:TextBox里面了。
- c#中字符可以 ls_str=@"aaaa bbb" vb中只能 "" & _ 这样连?
- 高手支支招啊!!
- 项目后期维护工作,安全性.....
- 水晶报表 PrintControl.cab
好像session丢失的情况不少啊
strUserName = TxtUserName.Text.Trim();
strPwd = TxtPwd.Text.Trim();
//判断数据库中该用户是否存在
if (obj.IsExistUserName(strUserName) == false)
{
Label1.Visible = true; //如果该用户不是合法用户,则显示label1
return;
}
if (Confirm(strUserName, strPwd))
{ //FormsAuthentication.RedirectFromLoginPage(strUserName,false);
//利用FormsAuthentication实现Form身份验证
//同时登录时建立登录信息的Cookie
//并在Cookie中保留身份验证信息,使登录后不再
//需要重新提交身份验证信息
FormsAuthentication.SetAuthCookie(strUserName, true);
//FormsAuthentication.SetAuthCookie(strPwd,true); HttpCookie cookie1 = new HttpCookie("UserName"); //建立HttpCookie的实例
//HttpCookie cookie2=new HttpCookie("PassWord"); cookie1.Values["UserName"] = strUserName;
//cookie2.Values["PassWord"]=strPwd; cookie1.Expires = DateTime.Now.AddDays(1); //获取或设置此cookie过期时间,保存Cookie一天
//cookie2.Expires=DateTime.Now.AddDays(1); Response.Cookies.Add(cookie1); //将实例加入到HttpResponse的cookies集合中,以便以后使用
//Response.Cookies.Add(cookie2);
Response.Redirect("index.aspx");
}
else
{
Label1.Visible = true;
return;
}
<system.web>
<sessionState mode="InProc" timeout="900" />
<httpRuntime executionTimeout="8000" maxRequestLength="5120" />
<!--
设置 compilation debug="true" 将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
validate="false" />
</httpHandlers>
<compilation debug="true">
<assemblies>
<add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
</compilation>
<!--
通过 <authentication> 节可以配置 ASP.NET 使用的
安全身份验证模式,
以标识传入的用户。
-->
<authentication mode="Forms"/>
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
开发人员通过该节可以配置
要显示的 html 错误页
以代替错误堆栈跟踪。
-->
<customErrors mode="On" defaultRedirect="systemerror.aspx">
</customErrors>
</system.web>
在登陆界面确定按钮中的程序中加入如下代码:Session.Timeout = 900;请问这样可以吗?
<system.web>
<sessionState mode="InProc" timeout="900" />
<httpRuntime executionTimeout="8000" maxRequestLength="5120" />
<!--
设置 compilation debug="true" 将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
validate="false" />
</httpHandlers>
<compilation debug="true">
<assemblies>
<add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
</compilation>
<!--
通过 <authentication> 节可以配置 ASP.NET 使用的
安全身份验证模式,
以标识传入的用户。
-->
<authentication mode="Forms"/>
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
开发人员通过该节可以配置
要显示的 html 错误页
以代替错误堆栈跟踪。
-->
<customErrors mode="On" defaultRedirect="systemerror.aspx">
</customErrors>
</system.web>
在登陆界面确定按钮中的程序中加入如下代码: Session.Timeout = 900; 请问这样可以吗?
<authentication mode="Forms">
<forms name="auth" loginUrl="default.aspx" timeout="60"></forms>
</authentication>定义了60分钟。60分钟不操作就需要重新登录了。
谢谢大家的回答。