Tag: webapi2

使用全局exceptionhandeling搞砸了DelegatingHandler

当遍历IExceptionHandler时,当发生意外exception时,响应不会到达DelegatingHandler。 我怎样才能解决这个问题? 在webapi 2中,我想为请求和响应消息实现审计记录器。 我还想添加一个全局exception处理程序。 但是,当我用我的自定义实现替换IExceptionHandler时。 响应永远不会到达DelegatingHandler -onexception – 因此对响应的审计将丢失。 在WebApiConfig中 // add custom audittrail logger config.MessageHandlers.Add(new AuditLogHandler()); // replace global exception handeling config.Services.Replace(typeof(IExceptionHandler), new WebAPiExceptionHandler()); 自定义exception处理程序 public class WebAPiExceptionHandler : ExceptionHandler { //A basic DTO to return back to the caller with data about the error private class ErrorInformation { public string Message { […]

WebApi2中的NHibernate – 更新和删除问题

插入,正确选择所有工作。 当我更新数据时,它不会更新到sql server(因为没有sql exec到服务器,在服务器中是旧数据不更新)。 但是当选择此记录时,它返回已更新的更新数据。 我重新启动iis服务器后,sql server返回旧数据,不通过选择更新。