Nancy
Nancy copied to clipboard
Nancy Razor View Compilation Errors do not invoke OnError pipeline
Description
Whenever there is a Razor view compilation error, Nancy does not forward it to the OnError pipeline, and when intercepting the response via IStatusCodeHandler it had ResponseCode value of 200 (OK), which is very unexpected behavior.
Steps to Reproduce
- Create a Nancy project with Razor ViewEngine using Self-Hosting;
- Add an item to the OnError Application Pipeline and set a breakpoint or log a message inside it;
- Add a NancyModule that returns
View["badView"]and create a view (with a syntax error in a c# block) namedbadview.cshtml; - Hit the created endpoint;
System Configuration
- Nancy version: 1.4.1
- Nancy host: Nancy.Hosting.Self
I have exactly the same problem.
- Nancy: 1.4.4
- Nancy.Viewengines.Razor: 1.4.3
If I see it correctly, this behavior cannot be changed because the view which is rendered in case of a compilation error is hard-coded (NancyRazorErrorView).
I've since migrated the application from Nancy to ASP.Net Core since it was still small, but is there any workaround, like for instance somehow checking if the view is a NancyRazorErrorView?