HttpNotFound v HttpStatusCodeResult


Posted on January 09, 2018

I happen to come accross some code that was along the lines of

return new HttpStatusCodeResult(404);

This is much better written as 

return HttpNotFound();

In fact if you decompile the System.Web.Mvc dll and see what is going on, you can see that HttpNotFound is doing that under the hood anyway. I just don't like seeing Http Status codes all over the place!

Decompiled assembly

-- Lee