I was trying to return an error to the call to the controller as advised in This link so that client can take appropriate action. The controller is called by javascript via
There is a very elegant solution to this problem, just configure your site via web.config:
Source: https://serverfault.com/questions/123729/iis-is-overriding-my-response-content-if-i-manually-set-the-response-statuscode