gpt4 book ai didi

asp.net-mvc-4 - 如何处理Umbraco中的500个服务器错误

转载 作者:行者123 更新时间:2023-12-03 08:54:37 25 4
gpt4 key购买 nike

我只想在发生服务器错误时创建自定义错误页面-我尝试了在Google上找到的建议的无尽组合,但什至没有任何东西可以使我到达那里。

本质上,我的表面 Controller 中有一些错误处理例程,我想记录错误然后抛出异常,以便在行下的某个地方返回500响应代码并显示自定义错误页面。

                try
{
repository.AddShoppingCartItem(sci);
}
catch(Exception e)
{
Log.Error("whatever...");
throw;
}

然后在我的web.config中,我尝试了
   <customErrors mode="On" defaultRedirect="error500">
</customErrors>


   <customErrors mode="On" defaultRedirect="umbraco/surface/error500surface">
</customErrors>

(第一个版本使用常规 Controller ,第二个使用表面 Controller )

也不做任何事。

我还按照其他人的建议添加了这一行,但这没什么区别:


我得到的是我的常规布局页面与以下消息一起呈现:

加载部分 View 脚本时出错(文件:〜/Views/MacroPartials/Addcart.cshtml)

我要发生的是改为显示自定义错误页面。

阅读Google上的所有内容后,对于是否需要配置Umbraco来处理这些错误,或者它是否是纯MVC方法,我感到完全困惑。我的印象是404错误是通过umbraco完成的,但500个错误必须是纯MVC方法。不知道是否有人可以确认这一点。无论哪种方式,链条上的东西都吞没了我的throw语句,我也不知道它是什么。

我也尝试过

返回新的HttpStatusCodeResult(500);

代替throw&只是让我讨厌的IIS错误页面。

任何帮助将不胜感激,因为这使我发疯。

最佳答案

500个错误是服务器错误,在Umbraco中与常规IIS中没有什么不同:

This is a server error and can only be solved by website admin who has access to files and the web-server. There can be one of/or multiple reasons to get this error. One has to track down the issue and handle accordingly.



http://www.codeproject.com/Articles/545054/HTTPplus-plus-e-plusInternalplusserverplus

更多信息:
https://serverfault.com/questions/407954/how-to-diagnose-a-500-internal-server-error-on-iis-7-5-when-nothing-is-written-t

编辑:显然您可以启用自定义错误,如下所示:
http://helpnotes.vpasp.com/kb/611-General-hosting-questions/1089-How-to-Turn-Off-Friendly-Error-in-IIS-7xx/

Edit2:这可能也很有趣:
http://benfoster.io/blog/aspnet-mvc-custom-error-pages

关于asp.net-mvc-4 - 如何处理Umbraco中的500个服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30545744/

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