Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpResponseException not accepting HttpStatusCode

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

The documentation on msdn says it has a constructor that accepts the HttpResponseMessage enum. http://msdn.microsoft.com/en-us/library/hh835324%28v=vs.108%29.aspx

What am I missing?

Thanks

like image 575
hofnarwillie Avatar asked Jun 05 '12 21:06

hofnarwillie


1 Answers

If you're using the RC, this has changed. Try:

throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized));
like image 153
smlync Avatar answered Sep 25 '22 11:09

smlync