Return http status code in asp.net mvc
Sometimes I need just return http status code as response to XHR call in asp.net mvc and it's really annoying, at least for me, fast googling how to do it.
So, let me share my first and fast tip how to return http response codes.
int error = 500;
return new HttpStatusCodeResult(error);
Also you can use build in response class HttpNotFoundResult() and HttpUnauthorizedResult() as shortcut.
More about HttpStatusCodeResult you can find on MSDN and http status codes are available on Wikipedia.
Written by Sebastian Bušek
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Asp.net mvc
Authors
xivsolutions
38.63K
vitaly_obukhov
3.916K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#