如何触发http 1.1 4xx 5xx错误代码? C#

时间:2011-07-11 02:19:36

标签: c# web-services http restful-authentication

如何在c#中使用http 1.1 4xx 5xx错误进行应用程序响应?

1 个答案:

答案 0 :(得分:4)

使用相应的HttpException投放HttpStatusCode

http://msdn.microsoft.com/en-us/library/system.web.httpexception.aspx

http://msdn.microsoft.com/en-us/library/system.net.httpstatuscode.aspx

示例:

throw new HttpException((int) HttpStatusCode.NotImplemented, "Requested function not supported");