我面临着处理MVC 4 webAPI中的错误的大问题。在这里,我想验证传入的请求并发回BadRequest响应。HttpResponseException
对于我使用的代码
public Product GetProduct(int id)
{
Product item = repository.Get(id);
if (item == null)
{
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
}
return item;
}
但在空号的情况下,VS2010会产生像
“HTTP请求导致的异常处理其他错误,请查看HTTP详情请参阅此例外的'Response'属性返回的响应。
我该如何解决这个问题提前
感谢....
您用哪个URL调用操作GetProduct? – 2012-08-14 07:42:18