I created an ASP.NET 5 application for Web API and installed Asp.Net.Diagnostics from NuGet so I could add my own error handling.

What works: (From Configuration function in Startup.cs)

app.UseErrorHandler("/Home/Error");
app.UseMvc(routes => {
    routes.MapRoute("Default", "{controller=Home}/{action=View}/{id?}");
});

What doesn't work: (app uses normal error handler instead of the custom one)

app.UseMvc(/*..configure routes..*/);
app.UseErrorHandler("/Home/Error");

Inside my controller I'm throwing:

throw new NotImplementedException("This method is not implemented");

I usually configure my big things first and the details later in case the details get overwritten. In this case, though, I need to configure my big thing (MVC) after my smaller thing (ErrorHandler), or my ErrorHandler doesn't work. Why is that?

Related posts

Recent Viewed