2

サービスを WebApi Action Filter (または DelegatingHandler) に注入する必要があります。Autofac では IAutofacActionFilter ( https://code.google.com/p/autofac/wiki/WebApiIntegration ) を使用できます。しかし、Orchard には Autofac の WebApi Dependecy Resolver はありません。Orchard のリゾルバ実装があります。

また、私はこれを試しました:

var service = (IMyService)GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IMyService));
or
var service = (IMyService)request.GetDependencyScope().GetService(typeof(IMyService));

しかし、それもうまくいきません。

4

0 に答える 0