OrchardCore: Error enabling OpenID module

When I enable a OpenID module, there is an error: InvalidOperationException: The connection does not support MultipleActiveResultSets.

image

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 34 (34 by maintainers)

Most upvoted comments

Hmm, maybe because of the following (see below).

    public ServiceScopeWrapper(IServiceScope serviceScope)
    {
        ServiceProvider = serviceScope.ServiceProvider;

        _serviceScope = serviceScope;
        _httpContext = ServiceProvider.GetRequiredService<IHttpContextAccessor>().HttpContext;
        _existingServices = _httpContext.RequestServices;
        _httpContext.RequestServices = ServiceProvider;  <==
    }

It allows a bgTask to use service as SiteService which do this

    private YesSql.ISession GetSession()
    {
        var httpContextAccessor = _serviceProvider.GetService<IHttpContextAccessor>();
        return httpContextAccessor.HttpContext.RequestServices.GetService<YesSql.ISession>();
    }
}

But when restarting a tenant i think the 1st time the bgTask execute it is in the context of the request. Hmm, maybe idem on the 1st request when starting the app.

So, when running concurently because of the bgTask timer, and in the context of the same request, even we enter in a new scope in a bgTask, we could share the same session through RequestServices. Maybe, as in O1 we would need to built a fake HttpContext when in the context of a bgTask.

Or, in BackgroundTaskService when we Activete() timer, maybe just start them immediately but don’t do anything in the 1st execution, or find a way to check if the request in which the timer has been started is not ended. Humm, easy to check through an IHttpContextAccessor.HttpContext object. I will try it.