How to make your application response with http 1.1 4xx 5xx error in C #?
Throw an HttpException using the appropriate HttpStatusCode .
HttpException
HttpStatusCode
http://msdn.microsoft.com/en-us/library/system.web.httpexception.aspx
http://msdn.microsoft.com/en-us/library/system.net.httpstatuscode.aspx
Example:
throw new HttpException((int) HttpStatusCode.NotImplemented, "Requested function not supported");