标签:iis asp-classic c
是否可以使用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是否有更多功能丰富的替代方案?
解决方法:
这是可能的.如果服务器上安装了Administration Pack,甚至还有一个向导可以帮助您从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();
}
}
}
标签:iis,asp-classic,c 来源: https://codeday.me/bug/20191111/2018657.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。