Autofac: Reference from a SingleInstance'd type to a HttpRequestScoped

Posted by Michael Wagner on Stack Overflow See other posts from Stack Overflow or by Michael Wagner
Published on 2010-04-08T11:58:33Z Indexed on 2010/04/08 14:13 UTC
Read the original article Hit count: 258

Filed under:
|
|

I've got an application where a shared object needs a reference to a per-request object.

Shared:      Engine
                |
Per Req:  IExtensions()
                |
             Request

If i try to inject the IExtensions directly into the constructor of Engine, even as Lazy(Of IExtension), I get a "No scope matching [Request] is visible from the scope in which the instance was requested." exception when it tries to instantiate each IExtension.

How can I create a HttpRequestScoped instance and then inject it into a shared instance?

Would it be considered good practice to set it in the Request's factory (and therefore inject Engine into RequestFactory)?

© Stack Overflow or respective owner

Related posts about autofac

Related posts about scope