【发布时间】:2013-07-22 16:20:29
【问题描述】:
我在这里按照解决方案实施了压缩:
但是,我的 Delete Web API 抛出异常:
public HttpResponseMessage Delete(int id)
{
if (_repo == null)
{
_uow = DependencyResolver.Current.GetService<TPS.Data.Can.IUnitOfWork>();
_repo = _uow.TradeSpendRepository;
}
if (!_repo.Delete(id))
{
return Request.CreateResponse(HttpStatusCode.NotFound);
}
_uow.Save();
return Request.CreateResponse(HttpStatusCode.OK);
}
在 CompressedContent 的构造函数中抛出异常,因为 content 为空:
if (content == null)
{
throw new ArgumentNullException("content");
}
我猜返回状态码是不够的!防止此异常的最佳方法是什么?
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-web-api