gpt4 book ai didi

asp.net - 我如何在不在 web.config 中的 httpErrors 上设置 defaultPath 的情况下指定自定义错误页面?

转载 作者:行者123 更新时间:2023-12-01 04:21:05 26 4
gpt4 key购买 nike

我目前正致力于将 asp.net 网站部署到共享托管环境,这按预期工作(呈现 404 页)

<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/file-not-found.htm" responseMode="ExecuteURL" />
</httpErrors>

但这不是(500 内部服务器错误)

<httpErrors errorMode="Custom" defaultPath="error.htm" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/file-not-found.htm" responseMode="ExecuteURL" />
</httpErrors>

我要求看一下 applicationHost.config,它有:

<httpErrors errorMode="Custom" defaultPath="C:\inetpub\custerr\en-US\SSLRedirect.htm" lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">

所以我假设 defaultPath 作为锁定属性是导致问题的原因。

因为这是部署到共享环境,托管公司不愿意修改 applicationHost.config 以解除对 defaultPath 的锁定 - 那么有没有办法在不解锁 defaultPath 属性的情况下指定默认错误页面?

最佳答案

在 global.asax 中,您可以只实现 Application_Error() 并重定向到您想要的任何地方吗?

关于asp.net - 我如何在不在 web.config 中的 httpErrors 上设置 defaultPath 的情况下指定自定义错误页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7924448/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com