【发布时间】:2016-09-02 03:23:07
【问题描述】:
这个 400 Bad Request 没有通过我的异常处理程序:
{
"message": "The request is invalid.",
"messageDetail": "The parameters dictionary contains a null entry for parameter 'subscriptionId' of non-nullable type 'System.Guid' for method 'System.Net.Http.HttpResponseMessage Get(System.Guid)' in 'Product.Controllers.ItemController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter."
}
在我的WebApiConfig.cs 我有这个:
config.Services.Replace(typeof(IExceptionHandler), new HttpExceptionHandler());
从操作、存储库、服务层级别抛出的每个异常都由此异常处理程序处理。但是对于这个错误,通用的 WebApi 异常处理程序会启动。
我应该如何解决这个问题才能让这个异常通过我的异常处理程序?
【问题讨论】:
标签: c# asp.net-web-api exception-handling