S
SAL
Hello,
I have a web app (asp.net 2.0) that I'm loosing Session variables in.
I implemented:
Application_End in Global.asax using the following code:
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
Dim b As Boolean
Try
b =
Convert.ToBoolean(ConfigurationManager.AppSettings("notifyOnAppShutDown"))
Catch ex As Exception
End Try
If Not b Then Exit Sub
Dim flgs As Reflection.BindingFlags
flgs = Reflection.BindingFlags.NonPublic Or
Reflection.BindingFlags.Static Or Reflection.BindingFlags.GetField
Dim runtime As HttpRuntime =
GetType(System.Web.HttpRuntime).InvokeMember("_theRuntime", flgs, Nothing,
Nothing, Nothing)
If runtime Is Nothing Then Return
Dim shutDownMessage As String
flgs = Reflection.BindingFlags.NonPublic Or
Reflection.BindingFlags.Instance Or Reflection.BindingFlags.GetField
shutDownMessage = runtime.GetType().InvokeMember("_shutDownMessage",
flgs, Nothing, runtime, Nothing)
Dim shutDownStack As String
shutDownStack = runtime.GetType().InvokeMember("_shutDownStack", flgs,
Nothing, runtime, Nothing)
' send email to me
SendMail.Send(vbCr & vbCr & shutDownMessage & vbCr & vbCr &
shutDownStack, "AnnexTrak Shutdown", _
Nothing, "(e-mail address removed)")
End Sub
And the app is indeed restarting pretty darned often. I was thinking this
might be a result of doing a Response.Redirect without the second parameter,
which the docs say calls End which in turn raises a ThreadAbortException.
This, likely, would cause the app to restart. However, I'm not seeing where
I'm doing that so my next thought was that a menu click could be doing this.
Is there a way to control that?
My menu is databound using the web.sitemap file so I'm not sure how to
control how it redirects to the page associated with that node of the menu.
It seems that most of the time the e-mail I get is the following in which it
doesn't list a cause of the shutdown:
HostingEnvironment caused shutdown
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Web.HttpRuntime.ShutdownAppDomain()
at System.Web.Hosting.HostingEnvironment.ShutdownThisAppDomainOnce()
at
System.Web.Hosting.HostingEnvironment.InitiateShutdownWorkItemCallback(Object
state)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object
state)
Any thoughts on this???
S
I have a web app (asp.net 2.0) that I'm loosing Session variables in.
I implemented:
Application_End in Global.asax using the following code:
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
Dim b As Boolean
Try
b =
Convert.ToBoolean(ConfigurationManager.AppSettings("notifyOnAppShutDown"))
Catch ex As Exception
End Try
If Not b Then Exit Sub
Dim flgs As Reflection.BindingFlags
flgs = Reflection.BindingFlags.NonPublic Or
Reflection.BindingFlags.Static Or Reflection.BindingFlags.GetField
Dim runtime As HttpRuntime =
GetType(System.Web.HttpRuntime).InvokeMember("_theRuntime", flgs, Nothing,
Nothing, Nothing)
If runtime Is Nothing Then Return
Dim shutDownMessage As String
flgs = Reflection.BindingFlags.NonPublic Or
Reflection.BindingFlags.Instance Or Reflection.BindingFlags.GetField
shutDownMessage = runtime.GetType().InvokeMember("_shutDownMessage",
flgs, Nothing, runtime, Nothing)
Dim shutDownStack As String
shutDownStack = runtime.GetType().InvokeMember("_shutDownStack", flgs,
Nothing, runtime, Nothing)
' send email to me
SendMail.Send(vbCr & vbCr & shutDownMessage & vbCr & vbCr &
shutDownStack, "AnnexTrak Shutdown", _
Nothing, "(e-mail address removed)")
End Sub
And the app is indeed restarting pretty darned often. I was thinking this
might be a result of doing a Response.Redirect without the second parameter,
which the docs say calls End which in turn raises a ThreadAbortException.
This, likely, would cause the app to restart. However, I'm not seeing where
I'm doing that so my next thought was that a menu click could be doing this.
Is there a way to control that?
My menu is databound using the web.sitemap file so I'm not sure how to
control how it redirects to the page associated with that node of the menu.
It seems that most of the time the e-mail I get is the following in which it
doesn't list a cause of the shutdown:
HostingEnvironment caused shutdown
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Web.HttpRuntime.ShutdownAppDomain()
at System.Web.Hosting.HostingEnvironment.ShutdownThisAppDomainOnce()
at
System.Web.Hosting.HostingEnvironment.InitiateShutdownWorkItemCallback(Object
state)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object
state)
Any thoughts on this???
S