I was building the ASP.NET service. In that service, when anything goes wrong like input data is not validated or some internal server error, I take that exception and then convert it to my JSON object, set Http ErrorCode to 500 and return JSON object to the client, but when I deployed that service to the production environment that is Windows Server 2008, IIS 7 then if anything went wrong so server didn't return my JSON object and the only thing which the server returned was the HTTP Error Code 500, well after scratching my head for one whole day, my colleague helped me out by setting the property on IIS. This is how we did it.
IIS->Sites->(DefaultWebSite or your Site)->Feature View->Double Click Error Pages->Edit Feature Settings -> select Detailed Errors -> press OK.
wuhhh, finally problem resolved.