【发布时间】:2012-12-05 15:38:33
【问题描述】:
我有一个 Windsor ASP.NET MVC WebAPI 项目设置,例如:
当我的控制器返回 OK 状态时,一切正常。但是,如果我尝试发送错误状态,例如 not 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”注释掉该行,那么一切正常。
【问题讨论】:
标签: c# asp.net-web-api castle-windsor