每次部署时都必须重置 Http 处理程序。如何将此功能添加到 web.config
我的应用程序是 dotnet 4 混合体 - 在某些领域是 MVC,在其他领域是 Web 表单。该应用程序最近升级到 dotnet 4,包含许多旧代码和一些不匹配的部分。不幸的是,它包含一个 telerik 组件,要求我以经典模式运行应用程序池。
为了解决这个问题(在 IIS7 中),我必须添加一个处理程序映射到 IIS 配置。此映射基本上是一个通配符映射,它将通配符路径“*”指向 %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll。
我遇到的问题是:由于某种原因,部署站点时此映射被删除。那么,我可以将此映射的功能添加到 Web 配置中吗?如果是这样,怎么办?
或者是否有另一种解决方案可以使此手动添加的映射“粘性”,以便在部署期间和部署后它保持在原位? (我也在 ServerFault 上问这个问题,因为我不确定这应该是编码问题还是服务器问题)
My application is a dotnet 4 hybrid - MVC in some areas, web forms in others. This application was recently upgraded to dotnet 4 and includes a lot of older code and some mismatched parts. Unfortunately it includes a telerik component that requires me to run the Application pool in classic mode.
In order to fix this (in IIS7) I have to add a handler mapping to the IIS configuration. This mapping is basically a wildcard mapping that points the wildcard path "*" to the %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll.
The problem I am running into is this: For some reason this mapping gets dropped when deploying the site. So, can I add the functionality of this mapping to the web config? If so, How?
Or is there another solution to make this manually added mapping "sticky" so that it remains in place during and after a deployment? (I am also asking this on ServerFault, as I'm not sure if this should be a coding question or a Server question)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我明白发生了什么;当您编辑处理程序映射并为单个站点添加自定义处理程序映射时,它实际上是通过向 system.webServer 部分添加“处理程序”元素(如果尚不存在)来编辑 Web 配置,并在其中添加通配符列表在我的例子中是这样的:
所以我复制了这些行并将它们放入我要部署到的环境的 web.config 中(在本例中是测试版 - 但我需要对生产执行相同的操作) 和 viola,该设置现已在部署时就位。发生的情况是,这些设置在每次部署期间都会丢失,因为(显然)web.config 被覆盖。
当我实际部署到生产环境时,我当然会更改 .dll 的路径以使用 %windir% 变量,以便它可以找到它正在寻找的内容!
Alright I figured out what was happening; When you edit the Handler mappings and add a custom one for a single site, it actually edits the web config by adding a 'handlers' element to the system.webServer Section (if it doesn't already exist), and within that it adds the wildcard listing which in my case is this:
so I copied these lines and put them in my web.config for the environment i'm deploying to (which is beta in this case -- but I will need to do the same for production) and viola, the setting is now in place upon deployment. What was happening is that these settings were being lost during each deployment because (obviously) the web.config was being overwritten.
When I actually do my deployment to production, I will of course change the path to the .dll to use the %windir% variable so it can find what it's looking for!
如果服务器上没有其他网站,则可以更改“根”网站的默认 IIS 设置 - 这些设置将在创建任何新网站时继承,这可能是您部署网站时发生的情况。
If you have no other web sites on the server, you can change the default IIS settings for the "root" web site - these will then be inherited when any new web site is created which is presumably what is happening when you deploy your site.