在web.config中指定相对路径

Rob*_*ior 5 asp.net web-config visual-studio-2010 asp.net-mvc-3

将MVC3 Asp.net应用程序部署到客户端站点后,我们遇到了问题.
在客户端站点中,已在IIS7中创建了我们需要部署的虚拟目录.

问题出在web.config中,我们在其中指定了自定义错误页面

<!-- Custom Error Pages -->
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" subStatusCode="-1" />
      <remove statusCode="500" subStatusCode="-1" />
      <remove statusCode="403" subStatusCode="-1" />
      <error statusCode="404" path="/Error/Http404" responseMode="ExecuteURL" />
      <error statusCode="403" path="/Error/Http403" responseMode="ExecuteURL" />
      <error statusCode="500" path="/Error/ServerError" responseMode="ExecuteURL" />
    </httpErrors>
Run Code Online (Sandbox Code Playgroud)

错误页面路径无法正常工作.经过调查,我们发现必须指定虚拟目录并设置路径/virtual_directory/Error/Http404

有没有办法可以指定相对于虚拟目录的路径?

Mic*_*ael 1

如果部署环境中的虚拟目录路径是恒定的,则此答案可能会使用不同的web.configweb.release.config文件满足您的目的。

如果虚拟目录路径可以变化,最初的提问者说这是不可能的