Skip to content

Instantly share code, notes, and snippets.

@bigsan
Created March 20, 2013 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigsan/5203558 to your computer and use it in GitHub Desktop.
Save bigsan/5203558 to your computer and use it in GitHub Desktop.
C#: ASP.NET - Stop HttpRuntime file changes monitoring
// http://stackoverflow.com/questions/613824/how-to-prevent-an-asp-net-application-restarting-when-the-web-config-is-modified
internal static class HttpInternals
{
private static readonly PropertyInfo s_FileChangesMonitor = typeof(HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Static);
private static readonly MethodInfo s_FileChangesMonitorStop = s_FileChangesMonitor.PropertyType.GetMethod("Stop", BindingFlags.NonPublic | BindingFlags.Instance);
private static object FileChangesMonitor
{
get
{
return s_FileChangesMonitor.GetValue(null, null);
}
}
public static void StopFileMonitoring()
{
//HttpRuntime.FileChangesMonitor.Stop();
s_FileChangesMonitorStop.Invoke(FileChangesMonitor, null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment