2017-06-15 4 views
2

パッケージを使用してlocationaspの設定を構成することはできますか?Microsoft.Web.Administrationを使用してASP設定を設定する

次のセクションをプログラムでローカルIIS applicationHost.configファイルに追加したいと思います。

<configuration> 
    ... 

    <location path="Default Web Site/myAppPath"> 
     <system.webServer> 
      <asp appAllowClientDebug="true" appAllowDebugging="true" enableParentPaths="true" scriptErrorSentToBrowser="true" /> 
     </system.webServer> 
    </location> 

</configuration> 

このセクションは、このパッケージを使用して維持できるすべてのサイトまたはアプリケーションに属していません。

そうでない場合は、Microsoft.Web.Administrationの機能豊富な代替手段はありますか?

答えて

2

可能です。サーバにAdministration Packがインストールされている場合、IISマネージャGUIからこのようなスクリプトを作成するのに役立つウィザードもあります。

IISマネージャ]> [サイト]> [既定のWebサイト>myAppPath>設定エディタ

Screenhotsは、既定のWebサイトのために採取したが、手順はあなたのような仮想アプリケーションで同じです。

IIS Configuration Editor

選択セクション(system.webServer/asp)と設定ファイル(ApplicationHost.config <location path="Default Web Site/myAppPath">)と変更を行います。

enter image description here

を適用]をクリックしないでください変更を行った後、ちょうどスクリプト生成]をクリックします。これにより、プログラムで変更を行うために使用できるスクリプトがいくつか用意されているダイアログが開きます。

Script Diaog

using System; 
using System.Text; 
using Microsoft.Web.Administration; 

internal static class Sample { 

    private static void Main() { 

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

      ConfigurationSection aspSection = config.GetSection("system.webServer/asp", "Default Web Site"); 
      aspSection["appAllowClientDebug"] = true; 
      aspSection["appAllowDebugging"] = true; 
      aspSection["enableParentPaths"] = true; 
      aspSection["scriptErrorSentToBrowser"] = true; 

      serverManager.CommitChanges(); 
     } 
    } 
} 
+0

うわー、詳細な回答のためにあなたをとても感謝しています。 –

+0

@ZoltánTamásiようこそ。 –

関連する問題