Nancy icon indicating copy to clipboard operation
Nancy copied to clipboard

Nancy Razor View Compilation Errors do not invoke OnError pipeline

Open henry701 opened this issue 7 years ago • 2 comments

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) named badview.cshtml;
  • Hit the created endpoint;

System Configuration

  • Nancy version: 1.4.1
  • Nancy host: Nancy.Hosting.Self

henry701 avatar Jun 24 '18 01:06 henry701

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).

RotenInformatik avatar Oct 14 '18 18:10 RotenInformatik

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?

henry701 avatar Oct 14 '18 21:10 henry701