c# - IIS 8.5 configuration on startup.cs (Azure webrole) -
using (servermanager servermanager = new servermanager()) { var config = servermanager.getapplicationhostconfiguration(); // configure iis compress requests coming through proxies (cdn). var httpcompressionsection = config.getsection("system.webserver/httpcompression"); httpcompressionsection["nocompressionforhttp10"] = false; httpcompressionsection["nocompressionforproxies"] = false; httpcompressionsection["staticcompressionignorehitfrequency"] = true; // configure iis threshold , time-period compression var serverruntimesection = config.getsection("system.webserver/serverruntime"); serverruntimesection["frequenthitthreshold"] = 1; serverruntimesection["frequenthittimeperiod"] = new timespan(24, 0, 0); // 1 day // configure iis compress files beforehand var urlcompressionsection = config.getsection("system.webserver/urlcompression"); urlcompressionsection["dynamiccompressionbeforecache"] = true; servermanager.commitchanges(); }
when run code locally, works expected (locally means windows 10 + iis express). when deploy webrole azure, machine (windows server 2012 r2 + iis) crashes.
i can't debug code on deployed machine (not knowledge @ least) i'm trying understand what's wrong code.
you should use error logging technology log4net create log of error being thrown.
try similar to:
try { using (servermanager servermanager = new servermanager()) { var config = servermanager.getapplicationhostconfiguration(); // configure iis compress requests coming through proxies (cdn). var httpcompressionsection = config.getsection("system.webserver/httpcompression"); httpcompressionsection["nocompressionforhttp10"] = false; httpcompressionsection["nocompressionforproxies"] = false; httpcompressionsection["staticcompressionignorehitfrequency"] = true; // configure iis threshold , time-period compression var serverruntimesection = config.getsection("system.webserver/serverruntime"); serverruntimesection["frequenthitthreshold"] = 1; serverruntimesection["frequenthittimeperiod"] = new timespan(24, 0, 0); // 1 day // configure iis compress files beforehand var urlcompressionsection = config.getsection("system.webserver/urlcompression"); urlcompressionsection["dynamiccompressionbeforecache"] = true; servermanager.commitchanges(); } } catch (exception e) { _log.errorformat("exception thrown during configuration! : {0}", e.tostring()); }
Comments
Post a Comment