You are here : Home » knowledge exchange


Issue C#: Delete directory kills session

issue C#: Delete directory kills session

In ASP.NET 2.0 the web application will recycle if a subdirectory is deleted.After you delete a directory the application will restart and you will loose all your session variables if you are using in-proc session. Put the following code in the Application_Start of your Global.asax: /FIX disable AppDomain restart when deleting subdirectory //This code will turn off monitoring from the root website directory. //Monitoring of Bin, App_Themes and other folders will still be operational, so updated DLLs will still auto deploy. System.Reflection.PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); object o = p.GetValue(null, null); System.Reflection.FieldInfo f = o.GetType().GetField("_dirMonSubdirs", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.IgnoreCase); object monitor = f.GetValue(o); System.Reflection.MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); m.Invoke(monitor, new object[] { });


Knowledge Exchange about Php Java, Asp.Net, SEO At Narola Infotech



Copyright © 2005-2012 Narola Infotech, Custom Software & Website Development Company | All Rights Reserved.

Find Us on