AUTOFAC is applied to the project, and when the global polling processing job needs to get the existing service, which has been configured through AUTOFAC, it is rightfully taken with the following code.
Dependencyresolver.current.getservice<clinicalcaseservice> ();
The result is a problem, directly throwing the error "the request lifetime scope cannot be created because the HttpContext are not available".
Result Crazy StackOverflow (address: https://stackoverflow.com/questions/21804857/ Autofac-the-request-lifetime-scope-cannot-be-created-because-the-httpcontext-i), find the solution.
Because HttpContext is required in autofacdependencyresolver.current internal GetService, the error is thrown directly.
Solution:
1,autofac
var resolver = new Autofacwebapidependencyresolver (container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
2, Get Service
Clinicalcaseservice = GlobalConfiguration.Configuration.DependencyResolver.GetService (typeof (Clinicalcaseservice )) as Clinicalcaseservice;
The request lifetime scope cannot be created because the HttpContext are not available