![](/img/trans.png)
[英]Using Microsoft.Web.Administration Application to change authentication mode
[英]Setting up ASP settings using Microsoft.Web.Administration
是否可以使用Microsoft.Web.Administration
包為給定location
配置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
還有更多功能豐富的替代品嗎?
這是可能的。 如果您的服務器上安裝了管理包 ,甚至還有一個向導可以幫助您從IIS管理器GUI創建此類腳本。
IIS管理器>站點>默認網站> myAppPath >配置編輯器
屏幕截圖是針對默認網站拍攝的,但像您這樣的虛擬應用程序的步驟是相同的。
選擇部分( system.webServer/asp
)和配置文件( ApplicationHost.config <location path="Default Web Site/myAppPath">
)並進行更改。
進行更改后, 請不要單擊“應用” ,只需單擊“ 生成腳本” 。 這將打開一個對話框,其中包含一些可用於以編程方式進行更改的腳本。
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();
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.