We are seeing an issue where our asp.net application is restarting every few hours. Based on event logs, we believe it is not caused by IIS restarts or Azure VM reboots. Also, we don't see unhandled exceptions in the event logs.
We have full access to the machines. How can we find more diagnostic information to root cause the restarts?
We have full access to the machines. How can we find more diagnostic information to root cause the restarts?
According to your description, I suggest you could try to follow this
answer to know how to use HostingEnvironment.ShutdownReason property in global.asax find out the application shutdown reason.
public class ApplicationPoolService : IApplicationPoolService
{
public bool IsShuttingDown()
{
return System.Web.Hosting.HostingEnvironment.ShutdownReason != ApplicationShutdownReason.None;
}
public ApplicationShutdownReason GetShutdownReason()
{
return System.Web.Hosting.HostingEnvironment.ShutdownReason;
}
}
public class HostingEnvironmentRegisteredObject : IRegisteredObject
{
public void Stop(bool immediate)
{
// second call is done when the Stop is imminent
if (immediate)
return;
var reason = appPoolService.GetShutdownReason().ToString();
logger.Log(LogLevel.Info, $"HostingEnvironmentRegisteredObject.stop called with shutdown reason {reason}");
}
}
// this code should be placed in global.asax.cs
protected void Application_Start()
{
HostingEnvironment.RegisterObject(new HostingEnvironmentRegisteredObject());
}
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
3 Posts
Asp.net application is restarting
Apr 04, 2019 06:14 PM|tgrunnagle|LINK
We are seeing an issue where our asp.net application is restarting every few hours. Based on event logs, we believe it is not caused by IIS restarts or Azure VM reboots. Also, we don't see unhandled exceptions in the event logs.
We have full access to the machines. How can we find more diagnostic information to root cause the restarts?
Star
9831 Points
3120 Posts
Re: Asp.net application is restarting
Apr 05, 2019 02:11 AM|Brando ZWZ|LINK
Hi tgrunnagle,
According to your description, I suggest you could try to follow this answer to know how to use HostingEnvironment.ShutdownReason property in global.asax find out the application shutdown reason.
Best Regards,
Brando
None
0 Points
3 Posts
Re: Asp.net application is restarting
Apr 09, 2019 05:13 PM|tgrunnagle|LINK
Thank you Brando. We were able to determine the shutdown reason is BinDirChangeOrDirectoryRename using your suggestion.
Is there any other information we can gather around this shutdown reason? E.g., which file changed.
All-Star
53631 Points
23991 Posts
Re: Asp.net application is restarting
Apr 09, 2019 05:36 PM|mgebhard|LINK
Does your application upload files to the bin directory? If so, change the process to save file in a different location.
All-Star
48690 Points
18171 Posts
Re: Asp.net application is restarting
Apr 11, 2019 11:31 AM|PatriceSc|LINK
Hi,
You tried File Explorer and https://www.howtogeek.com/219157/how-to-easily-view-recently-modified-files-in-windows/ to check which files or directories were touched ?
Or a solution wide search for "bin" with the whole word option maybe should allow to find if you have code that tries to write there ?
None
0 Points
3 Posts
Re: Asp.net application is restarting
Apr 11, 2019 03:55 PM|tgrunnagle|LINK
We found the culprit by using the file explorer. Thanks for your help.