//---------------------------------------------------------------------
//Aspect Filters
public class RequestAspectAttribute : RequestFilterAttribute {
public RequestAspectAttribute() { } //debug point was hit
public RequestAspectAttribute(ApplyTo applyTo) : base(applyTo) { }
public override void Execute(IHttpRequest req, IHttpResponse res, object reqDto) {
//This code is executed before the service
//debug point was hit
}
}
public class ResponseAspectAttribute : ResponseFilterAttribute {
public ResponseAspectAttribute() { } //debug point was NOT hit
public ResponseAspectAttribute(ApplyTo applyTo) : base(applyTo) { }
public override void Execute(IHttpRequest req, IHttpResponse res, object resDto) {
//This code is executed after the service
//debug point was NOT hit
}
}
//---------------------------------------------------------------------
//REST Service
[RequestAspect]
[ResponseAspect]
public class TodoService : RestServiceBase<Todo> { ...
我正在使用上面的代码测试 ToDo List 示例项目中的 Req/Res 过滤器属性。因此,除了两个附加属性外,示例项目(我认为)没有任何其他更改。
当我添加一个待办事项时,只调用了请求属性。响应属性没有被触发。
在这种情况下,他们不应该在休息呼叫之前和之后成对启动吗?是我的理解不正确还是我做错了什么?提前感谢您的帮助。