Autofac with asp.net mvc 5 async

467 views
Skip to first unread message

do...@silverkeytech.com

unread,
Apr 19, 2015, 12:00:11 PM4/19/15
to aut...@googlegroups.com
I got this exception 'The request lifetime scope cannot be created because the HttpContext is not available.' after switching my action to async.

foreach (var handler in DependencyResolver.Current.GetServices<Handles<T>>())

I am using Autofac.Mvc5 3.3.3 on asp.net mvc 5.2.3.

I checked on this question on StackOverflow and it mentioned that this problem should not have happened anymore

http://stackoverflow.com/questions/21804857/autofac-the-request-lifetime-scope-cannot-be-created-because-the-httpcontext-i

Any tips is much appreciated.

Travis Illig

unread,
Apr 20, 2015, 12:27:56 PM4/20/15
to aut...@googlegroups.com, do...@silverkeytech.com
Can you provide the whole stack trace so we can see exactly where the error is occurring?

Also, can you add a breakpoint right at the foreach and see what HttpContext.Current is? (Is it null or is there a value?)

-T

ca...@liquidfusion.com.au

unread,
Aug 30, 2016, 9:58:25 AM8/30/16
to Autofac, do...@silverkeytech.com
A late reply but hopefully can help somebody, It sounds like you are trying to resolve the dependency from a thread which doesn't have access to HttpContext.
Reply all
Reply to author
Forward
0 new messages