tags:

views:

17

answers:

1

I have static content like html,css javascript stored in DB. when a user requests for these i create a temp file in virtual directory and return the url.

My web app is hosted on a IIS server. On some systems on creation of a file my IIS Application pool crashes and restarts. If i disable file-monitoring though the problem is resolved, but i dont have this luxury when i am deplying at the client end.

Is there any way by which i can avoid app pool crash during file creation?

If not is there any way by which i can serve static content like html, css, images, xml and js without creating temp files. I would need a generalized way of handling all these data types.

A: 

Found a code snippet which executed in the application start event disable File Change Notification on the root web folder

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); //Returns NULL

System.Reflection.MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); m.Invoke(monitor, new object[] { });

There is another snippet with slight variation

var theRuntime = typeof(HttpRuntime).GetField("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
var fcmField = typeof(HttpRuntime).GetField("_fcm", BindingFlags.NonPublic | BindingFlags.Instance);

var fcm = fcmField.GetValue(theRuntime);
fcmField.FieldType.GetMethod("Stop", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(fcm, null);

In both cases the script needs admin privilages to run succesfully(tried using a guest account and failed)

Vinay B R