I have a Windsor ASP.NET MVC WebAPI project setup like:
Everything works fine when my controller returns an OK status. However, if I try to send an error status, like not NotFound, then I get the following error:
Castle.MicroKernel.Lifestyle.Scoped.CallContextLifetimeScope+SerializationReference,Castle.Windsor, Version=3.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
Here is my controller method:
// GET api/values
public IEnumerable<string> Get()
{
bool valid = ...;
if (valid)
return new[] {"valid"};
HttpResponseMessage resp = new HttpResponseMessage(HttpStatusCode.NotFound);
resp.Content = new StringContent("My custom message");
throw new HttpResponseException(resp);
}
Notice, if I comment out the line with "resp.Content", then everything works fine.