NancyFx/Nancy — pull request #1316 by davidalpert (2013-11-08 20:27:37+00:00)
Title: Razor view compilation errors will now return a 500 response code

I was recently surprised to learn that requesting a Razor view in Nancy would return a status 200 OK even when the view failed to compile.

An xUnit test to document my expectation is included in the pull request and can be reviewed below.

The core change I made to the Nancy RazorViewEngine was to move rendering of the body's HTML out of the Response.Content Action delegate and complete it before returning the Response object so that any rendering issues could be discovered and the Response's StatusCode property set properly before returning the Response to the infrastructure.

All existing RazorViewEngine tests continue to pass for me after this change.