web.config中相对路径的正确语法是什么?

时间:2013-11-01 15:48:46

标签: iis web-config relative-path isapi handlers

我有这样的网站结构:

enter image description here

我想在web.config中为ISAPI应用程序使用test_isapi.dll的相对路径。我尝试用以下相对路径替换C:\TestSite1\TestSite2\ISAPI\test_isapi.dll但没有运气:

  • test_isapi.dll
  • ~/test_isapi.dll
  • ~\test_isapi.dll
  • ISAPI\test_isapi.dll

我的相对路径的语法是否有误,或者这对于配置中的处理程序设置是不可能的?

当前(使用绝对路径)web.config(TestSite1 / TestSite2 / ISAPI / web.config):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="Test ISAPI"
           path="*"
           verb="*"
           modules="IsapiModule"
           scriptProcessor="C:\TestSite1\TestSite2\ISAPI\test_isapi.dll"
           resourceType="Unspecified"
           requireAccess="None"
           preCondition="bitness32" />
    </handlers>
  </system.webServer>
</configuration>

3 个答案:

答案 0 :(得分:1)

我的解决方案是以编程方式检查并添加处理程序映射,而不是使用web.config部署设置。这样我就可以在运行时确定绝对路径并应用设置。不理想,但它完成了工作。

请参阅此答案:How to add IIS handler mapping programmattically

答案 1 :(得分:-1)

config你可以写〜/ filepath

答案 2 :(得分:-1)

要使用相对路径,只需为ISAPI站点webconfig添加 ~/test_isapi.dll