不断收到查看"错误"使用ELMAH和asp.net的MVC 4时,未找到 [英] keep getting The view "Error" not found when using Elmah and asp.net mvc 4
问题描述
我使用ELMAH 1.2作为我的asp.net mvc的4应用程序中的日志框架。
I am using Elmah 1.2 as the logging framework for my asp.net mvc 4 application.
在web.config文件中,我对设置的customErrors模式。
in the web.config file, I set customErrors mode to on.
<customErrors mode="On" defaultRedirect="/Error">
<error statusCode="404" redirect="/Error/NotFound" />
</customErrors>
我还创建一个自定义HandleErrorAttribute,从这个链接复制code。
I also created a custom HandleErrorAttribute, copied the code from this link.
的http://joel.net/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute
在我家的控制器,我只是抛出一个异常,测试日志框架。
In my Home controller, i just throw an exception to test the logging framework.
public ActionResult About()
{
throw new Exception("this is a buggggggggggggg");
ViewBag.Message = "Your app description page.";
return View();
}
这是一个buggggggggggggg数据库中的记录,伟大的,它的工作原理。再有就是另一个错误也记录下来,和我没有想到这样的事情发生。
"this is a buggggggggggggg" is logged in the database, great, it works. then there's another error also logged, and I didnt expect that to happen.
视图错误或它的主人没有被发现或没有视图引擎支持搜索位置。在以下地点进行了全面搜查:〜/查看/主页/ Error.aspx〜/查看/主页/ Error.ascx〜/查看/共享/ Error.aspx〜/查看/共享/ Error.ascx〜/查看/主页/错误。 CSHTML〜/查看/主页/ Error.vbhtml〜/查看/共享/ Error.cshtml〜/查看/共享/ Error.vbhtml
The view 'Error' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Home/Error.aspx ~/Views/Home/Error.ascx ~/Views/Shared/Error.aspx ~/Views/Shared/Error.ascx ~/Views/Home/Error.cshtml ~/Views/Home/Error.vbhtml ~/Views/Shared/Error.cshtml ~/Views/Shared/Error.vbhtml
更新:
跟随蒂姆的建议,那么它会导致另一个问题。
follow Tim's suggestion, then it causes another issue.
如果我在共享文件夹中创建Error.cshtml。当未处理的异常发生时,它会显示这个Error.cshtml文件,而不是/错误页面。我启用的customErrors。他们都应该重定向到/错误页面。
If I create a Error.cshtml in the shared folder. when unhandled exception happens, it will show this Error.cshtml file, not "/Error" page. I have customErrors enabled. They should all get redirected to "/Error" page.
推荐答案
我们创建了一个空MVC5应用程序,并添加ELMAH它。我们也正在接受你所说,即使我们没有添加HandleErrorAttribute额外的错误。经过一番研究,我发现的NuGet包 Elmah.MVC
它增加了一些额外的配置设置。在的web.config
的的appSettings
部分,你会发现这些2号线:
We created an empty MVC5 app and added ELMAH to it. We also were receiving the extra error you described even though we did not add the HandleErrorAttribute. After some research I found the nuget package Elmah.MVC
which adds some additional configuration settings. In the appSettings
section of web.config
you will find these 2 lines:
<appSettings>
<add key="elmah.mvc.disableHandler" value="false" />
<add key="elmah.mvc.disableHandleErrorFilter" value="false" />
</appSettings>
这2个键默认为假。我改变了自己的价值观,以真和额外的记录的异常走。
These 2 keys default to "false". I changed their values to "true" and the extra logged exception went away.
这篇关于不断收到查看&QUOT;错误&QUOT;使用ELMAH和asp.net的MVC 4时,未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!