Add custom status code to all responses in mvc web api

Posted by Jpchoudhari under ASP.NET Web API on 3/3/2015 | Points: 10 | Views : 2122 | Status : [Member] | Replies : 0
I am using 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,


(No response found.)

Login to post response