Add custom status code to all responses in asp.net mvc web api

Posted by Jpchoudhari under ASP.NET Web API on 3/3/2015 | Points: 10 | Views : 2357 | Status : [Member] | Replies : 0
I am using asp.net web api and I want to send proper status code along with the response. Currently it always returns 200 OK status.

I would like to send different response status like

on POST 201 Record Created
on PUT 205 Record Modified
on PUT 412 Validation Failed
on DELETE 204 Record Deleted etc.

These are quite standard status codes I found and all actions in web api accepts these request types.

I am currently struggling to find a clear example of how, in one place (most probably via action filter or http module) I can add that status code.

Kind Regards,
Jay



Responses

(No response found.)

Login to post response