我们在将MVC3 Asp.net应用程序部署到客户网站后遇到了问题。
在客户网站中,已经在IIS7中创建了一个虚拟目录,我们需要将应用程序部署到这个目录中。
问题出现在web.config文件中,我们指定了自定义错误页面。
在客户网站中,已经在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>
错误页面路径无法正常工作。经过调查,我们发现必须指定虚拟目录并将路径设置为/virtual_directory/Error/Http404
。
有没有一种方法可以相对于虚拟目录来指定路径?
path="~/Error/Http404"
,但恐怕行不通:http://www.iis.net/configreference/system.webserver/httperrors/error。"如果你选择ExecuteURL响应模式,路径必须是服务器相对URL(例如,/404.htm)"。 - jbl