Windsor ASP.NETMVCWebAPIプロジェクトのセットアップは次のようになっています。
コントローラがOKステータスを返すと、すべて正常に動作します。ただし、NotFoundなどのエラーステータスを送信しようとすると、次のエラーが発生します。
Castle.MicroKernel.Lifestyle.Scoped.CallContextLifetimeScope + SerializationReference、Castle.Windsor、Version = 3.1.0.0、Culture = neutral、PublicKeyToken = 407dd0808d44fbdc
これが私のコントローラーメソッドです:
// 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);
}
「resp.Content」という行をコメントアウトすると、すべてが正常に機能することに注意してください。