如何从命令行添加自定义HTTP头到IIS [英] How to add custom HTTP Headers to IIS from the command line

查看:167
本文介绍了如何从命令行添加自定义HTTP头到IIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个ASP.NET应用程序,我需要为团队中的所有开发人员添加一个自定义HTTP头到IIS,所以我想在NANT脚本中添加一个命令,当构建脚本时添加HTTP头运行。甚至可以从命令行执行此操作。

We have an ASP.NET application and I need to add a custom HTTP header to IIS for all the developers on the team, so I want to add a command in the NANT script that will add the HTTP Header when the build script is run. Is it even possible to do this from the command line.

我一直在查找 cscript adsutil.vbs 上的文档,但我找不到任何specfic这个问题。

I've been looking up the documentation on cscript adsutil.vbs but I can't find anything specfic to this issue.

推荐答案

找到解决方案。显然我没有看起来很难,这是命令行设置自定义HTTP头:

Ok solution found. Clearly I wasn't looking hard enough, this is the command line to set the Custom HTTP Headers:

cscript adsutil.vbs set w3svc/HttpCustomHeaders "X-Powered-By: ASP.NET" "HeaderName2: value" "HeaderName3: value" 

这需要从c:\Inetpub\AdminScripts文件夹运行。

this needs to be run from the c:\Inetpub\AdminScripts folder.

作为一个奖励,这里是nant命令在一个构建脚本:

As a bonus, here's the nant command to do it in a build script:

<exec workingdir="c:\Inetpub\AdminScripts" program="cscript.exe" commandline="adsutil.vbs set W3SVC/1/ROOT/Insurance/HttpCustomHeaders &quot;X-Powered-By: ASP.NET&quot; &quot;HeaderName2: value&quot; &quot;HeaderName3: value&quot;" />

通过 IIS故障排除,管理和概念

这篇关于如何从命令行添加自定义HTTP头到IIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆