本文介绍了HTT presponseException不接受的HTTPStatus code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想提出一个的Htt presponseException
在此截屏描述(约1分钟)
I am trying to raise a HttpResponseException
as described in this screencast (about 1 minute in)
throw new HttpResponseException(HttpStatusCode.Unauthorized);
但应用程序将无法编译,因为它引发以下错误:
But the app won't compile as it throws the following error:
The best overloaded method match for 'System.Web.Http.HttpResponseException.HttpResponseException(System.Net.Http.HttpResponseMessage)' has some invalid arguments
在MSDN文档说,它有一个接受的Htt presponseMessage
枚举的构造函数。 http://msdn.microsoft.com/en-us/library/hh835324%28v=vs.108%29.aspx
我是什么失踪?
感谢
推荐答案
如果您使用的RC,这种情况已经改变。尝试:
If you're using the RC, this has changed. Try:
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized));
这篇关于HTT presponseException不接受的HTTPStatus code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!