In ASP.NET MVC, what is the difference between returning this:
return new HttpStatusCodeResult(HttpStatusCode.NotFound);
and this:
return HttpNotFound();
The difference is that HttpStatusCodeResult
gives you more control over which HTTP status code you can return as it allows you to specify any of the predefined status codes in the HttpStatusCode
enum. HttpNotFound
always returns the HTTP status code 404.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With