My asp code:
Expand|Select|Wrap|Line Numbers
- void Session_End(object sender, EventArgs e)
- {
- // Code that runs when a session ends.
- // Note: The Session_End event is raised only when the sessionstate mode
- // is set to InProc in the Web.config file. If session mode is set to StateServer
- // or SQLServer, the event is not raised.
- string domainName = AppDomain.CurrentDomain.BaseDirectory.ToString();
- string strDirName = domainName.Replace("bin\\Debug\\", "");
- string enableLogging = ConfigurationSettings.AppSettings.Get("EnableSessionLog");
- if (enableLogging.ToLower() == "true")
- {
- TextWriter tw = new StreamWriter(strDirName + "Log Files\\SessionLog.txt", true);
- if (Session["portalID"] != null)
- {
- tw.WriteLine("Session Ends");
- tw.WriteLine(DateTime.Now + " SessionTimedout SessionID = " + Session.SessionID);
- tw.WriteLine(DateTime.Now + " SessionTimedout UserName = " + Session["session_username"].ToString());
- tw.WriteLine(DateTime.Now + " SessionTimedout PortalID = " + Session["portalID"].ToString());
- tw.WriteLine(DateTime.Now + " SessionTimedout PatientID = " + Session["patientID"].ToString());
- }
- tw.Close();
- }
- }
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 8/20/2009 11:19:24 AM
Event time (UTC): 8/20/2009 5:49:24 AM
Event ID: 7d1169968dd9490 2bc75c75234933e 12
Event sequence: 968
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: b42109ff-1-128952191043738 926
Trust level: Full
Application Virtual Path: /ApplicationName
Application Path: C:\ApplicationN ame\
Machine name: MachineName
Process information:
Process ID: 3576
Process name: WebDev.WebServe r.EXE
Account name: MachineName\Adm inistrator
Exception information:
Exception type: NullReferenceEx ception
Exception message: Object reference not set to an instance of an object.
Request information:
Request URL:
Request path:
User host address:
User:
Is authenticated: False
Authentication Type:
Thread account name: MachineName\Adm inistrator
Thread information:
Thread ID: 10
Thread account name: MachineName\Adm inistrator
Is impersonating: False
Stack trace: at ASP.global_asax .Session_End(Ob ject sender, EventArgs e) in c:\ApplicationN ame\Global.asax :line 80
I got the warning in this line- tw.WriteLine(Da teTime.Now + " SessionTimedout UserName = " + Session["session_userna me"].ToString());
After session end i tried to write the session value.Please any one tell me how to avoid this