7

So I am trying to figure out a method that can render a error message if my model is null and after that error message the view should stop rendering, is this possible? My first thought was the response.end() method but then the master view won't finish rendering. Is this somthing thats part of the framework our do need to build it myself??

3 Answers 3

14

Just using a return statement worked for me. So:

return;
4

This logic should really sit in a controller which would choose to render the correct view based on the presence or absence of the model.

This keeps the ASP MVC pipeline in-tact and eliminates the need for view shortcuts.

1

Don't see how you model could suddenly be null...

But conceptually sound way to address the situation would be to check the model for null in your controller action and then redirect to an error view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.