简体   繁体   English

使用Powershell在IIS中注册处理程序模块

[英]Register Handler Module in IIS with Powershell

I have problem with IIS and web.config. 我在IIS和web.config中遇到问题。 I deploy a website by copying it on a new computer. 我通过将网站复制到新计算机上来部署网站。 The website I copy contains the web.config, and the dll I want to register as a Handler Mapping. 我复制的网站包含web.config和要注册为处理程序映射的dll。 So my web.config already looks like : 所以我的web.config已经看起来像:

<configuration>
<system.webServer>
    <handlers>
        <add name="MyHandler" path="*.dll" verb="*" modules="IsapiModule" scriptProcessor="C:\inetpub\wwwroot\test\Scripts\MyHandler.dll" resourceType="Unspecified" preCondition="bitness64" />
    </handlers>
</system.webServer>

It's visible and listed when I click on the Handler Mappings in IIS. 当我在IIS中单击“处理程序映射”时,它是可见的并列出。 But after the copy and rebooting of IIS, it's not taken into account. 但是,在复制并重新启动IIS之后,没有考虑到它。 For it to be taken into account, I need to manually edit the mapping on IIS, then click Ok. 为了将其考虑在内,我需要在IIS上手动编辑映射,然后单击“确定”。 At that point, I have prompt confirming that it will be taken into account. 在这一点上,我迅速确认将予以考虑。

The problem is, I want to deploy this site with a Powershell script. 问题是,我想使用Powershell脚本部署此站点。 It seems a simple copy + IIS reboot is not enough. 似乎简单的复制+ IIS重新启动是不够的。

What should I do for this handler mapping be taken into account with Powershell? Powershell应该如何处理此处理程序映射?

I continued researching and find my own answer. 我继续研究并找到自己的答案。 I need to add it in the CGI and Retriction List using Powershell: 我需要使用Powershell将其添加到CGI和限制列表中:

Add-WebConfiguration "/system.webServer/security/isapiCgiRestriction" -Value @{path="C:\inetpub\wwwroot\test\Scripts\MyHandler.dll" ; allowed="true"}

and then it works. 然后它起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM