Search code examples
c#asp.netweb-applicationsiis-7application-pool

Application pool restart automaticly if file change in repositery


Why does the application restart automatically when we create a new folder under a web site in IIS 7.0 or Cassini?

Is it a config we can change ? What is the impact ?

I read this post and the post not answer to my question


Solution

  • I found a solutions.

    There is the link

    Put this code in the application start of the global.asax

    PropertyInfo p = typeof(HttpRuntime).GetProperty("FileChangesMonitor", 
                    BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); 
    
                object o = p.GetValue(null, null); 
    
                FieldInfo f = o.GetType().GetField("_dirMonSubdirs", 
                    BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase); 
    
                object monitor = f.GetValue(o); 
    
                MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", 
                    BindingFlags.Instance | BindingFlags.NonPublic); 
    
                m.Invoke(monitor, new object[] { });