我正在尝试实现自定义服务挂钩,这就是我到目前为止所做的......
全球.asax
public override IServiceRunner<TRequest> CreateServiceRunner<TRequest>(ActionContext actionContext)
{
return new MyServiceRunner<TRequest>(this, actionContext);
}
MyServiceRunner.cs
public class MyServiceRunner<T> : ServiceRunner<T> {
public override void OnBeforeExecute(IRequestContext requestContext, TRequest request) {
// Called just before any Action is executed
}
public override object OnAfterExecute(IRequestContext requestContext, object response) {
// Called just after any Action is executed, you can modify the response returned here as well
}
public override object HandleException(IRequestContext requestContext, TRequest request, Exception ex) {
// Called whenever an exception is thrown in your Services Action
}
}
在 global.asax 中,返回语句显示错误“构造函数 MyServiceRunner 有 0 个参数,但使用 2 个参数调用”。
有人可以帮助我吗...如果可以的话,我绝对需要使用 actionContext。