【发布时间】:2012-06-05 21:21:17
【问题描述】:
我正在尝试提出HttpResponseException,如此截屏视频中所述(大约 1 分钟)
throw new HttpResponseException(HttpStatusCode.Unauthorized);
但应用程序无法编译,因为它会引发以下错误:
The best overloaded method match for 'System.Web.Http.HttpResponseException.HttpResponseException(System.Net.Http.HttpResponseMessage)' has some invalid arguments
msdn 上的文档说它有一个接受HttpResponseMessage 枚举的构造函数。 http://msdn.microsoft.com/en-us/library/hh835324%28v=vs.108%29.aspx
我错过了什么?
谢谢
【问题讨论】:
-
你也可以发布你的实际代码吗?
-
当您创建 HttpResponseException 并点击正确的括号时,您看到文档显示的两个构造函数还是只有一个?如果只有一个,那么您仅限于 HttpResponseMessage....或者....您使用的框架版本与文档不同。
标签: c# asp.net http httpresponse asp.net-web-api