我正在尝试实现自定义服务挂钩,这是我到目前为止所做的...
的global.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。
答案 0 :(得分:2)
你需要一个构造函数,它应该是:
public class MyServiceRunner<T> : ServiceRunner<T>
{
public MyServiceRunner(IAppHost appHost, ActionContext actionContext)
: base(appHost, actionContext) {}
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
}
public override object HandleException(IRequestContext requestContext,
TRequest request, Exception ex) {
// Called whenever an exception is thrown in your Services Action
}
}