【发布时间】:2014-01-22 23:48:51
【问题描述】:
如果错误存在,我会在我测试的有效负载中使用会话编写代码:
protected void Page_Load(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(Session["id"].ToString())) QueryStringError.SessionNotFound(Response);
else
{
如果会话不存在,我会重定向到某个页面......但一段时间后我收到了这些错误:
Server Error in '/Redcrescent' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 11: protected void Page_Load(object sender, EventArgs e)
Line 12: {
Line 13: if (String.IsNullOrEmpty(Session["id"].ToString())) QueryStringError.SessionNotFound(Response);
Line 14: else
Line 15: {
Source File: c:\Users\Samy\Documents\Visual Studio 2010\WebSites\Redcrescent\User\UserPrivilegeManage.aspx.cs Line: 13
会话超时已完成,但为什么它给了我应该重定向的错误而不是抛出错误
在 web.config 文件中:
<sessionState cookieless="true"
regenerateExpiredSessionId="true"
timeout="525600" mode="InProc" stateNetworkTimeout="525600"
/>
但仍然没有工作......有什么想法吗? 如何使会话永不过期?以及如何解决这些错误?
【问题讨论】: