keep getting The view "Error" not found when using Elmah and asp.net mvc 4 -
i using elmah 1.2 logging framework asp.net mvc 4 application.
in web.config file, set customerrors mode on.
<customerrors mode="on" defaultredirect="/error"> <error statuscode="404" redirect="/error/notfound" /> </customerrors> i created custom handleerrorattribute, copied code link.
http://joel.net/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute
in home controller, throw exception test logging framework.
public actionresult about() { throw new exception("this buggggggggggggg"); viewbag.message = "your app description page."; return view(); } "this buggggggggggggg" logged in database, great, works. there's error logged, , didnt expect happen.
the view 'error' or master not found or no view engine supports searched locations. following locations 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
update:
follow tim's suggestion, causes issue.
if create error.cshtml in shared folder. when unhandled exception happens, show error.cshtml file, not "/error" page. have customerrors enabled. should redirected "/error" page.
we created empty mvc5 app , added elmah it. receiving error described though did not add handleerrorattribute. after research found nuget package elmah.mvc adds additional configuration settings. in appsettings section of web.config find these 2 lines:
<appsettings> <add key="elmah.mvc.disablehandler" value="false" /> <add key="elmah.mvc.disablehandleerrorfilter" value="false" /> </appsettings> these 2 keys default "false". changed values "true" , logged exception went away.
Comments
Post a Comment