2016-04-19 13 views
0
using (ServerManager serverManager = new ServerManager()) 
{ 
    var config = serverManager.GetApplicationHostConfiguration(); 

    // Configure IIS to compress for requests coming through proxies (CDN). 
    var httpCompressionSection = config.GetSection("system.webServer/httpCompression"); 
    httpCompressionSection["noCompressionForHttp10"] = false; 
    httpCompressionSection["noCompressionForProxies"] = false; 
    httpCompressionSection["staticCompressionIgnoreHitFrequency"] = true; 

    // Configure IIS threshold and time-period for compression 
    var serverRuntimeSection = config.GetSection("system.webServer/serverRuntime"); 
    serverRuntimeSection["frequentHitThreshold"] = 1; 
    serverRuntimeSection["frequentHitTimePeriod"] = new TimeSpan(24, 0, 0); // 1 day 

    // Configure IIS to compress files beforehand 
    var urlCompressionSection = config.GetSection("system.webServer/urlCompression"); 
    urlCompressionSection["dynamicCompressionBeforeCache"] = true; 

    serverManager.CommitChanges(); 
} 

このコードをローカルで実行すると、すべてが期待通りに機能します(ローカルではWindows 10 + IISが高速です)。 このWebロールをAzureにデプロイすると、私のマシン(Windows server 2012 R2 + IIS)がクラッシュします。スタートアップ時のIIS 8.5構成(Azure webrole)

私はこのコードを間違って理解しようとしていますので、私の配備したマシンでこのコードをデバッグすることはできません。

答えて

1

スローされているエラーのログを作成するには、log4netのようなエラーロギングテクノロジを使用する必要があります。私が見

try { 
     using (ServerManager serverManager = new ServerManager()) 
     { 
      var config = serverManager.GetApplicationHostConfiguration(); 

      // Configure IIS to compress for requests coming through proxies (CDN). 
      var httpCompressionSection = config.GetSection("system.webServer/httpCompression"); 
      httpCompressionSection["noCompressionForHttp10"] = false; 
      httpCompressionSection["noCompressionForProxies"] = false; 
      httpCompressionSection["staticCompressionIgnoreHitFrequency"] = true; 

      // Configure IIS threshold and time-period for compression 
      var serverRuntimeSection = config.GetSection("system.webServer/serverRuntime"); 
      serverRuntimeSection["frequentHitThreshold"] = 1; 
      serverRuntimeSection["frequentHitTimePeriod"] = new TimeSpan(24, 0, 0); // 1 day 

      // Configure IIS to 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()); 
    } 
+0

は次のように何かを試してみてください。だから、基本的に私のコードで何の問題も見つけられないのですか? – johni

+0

私にはわかりませんが、コードをデバッグするのに役立つログを追加することによって、自分自身を助けることができます。 ;) – toadflakz

関連する問題