0

When I'm send two or more ajax requests to same controller on one page I got the following error:

The request lifetime scope cannot be created because the HttpContext is not available.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The request lifetime scope cannot be created because the HttpContext is not available.

Source Error:


Line 20:             get
Line 21:             {
Line 22:                 return DependencyResolver.Current.GetService<ISessionService>();
Line 23:             }
Line 24:         }
jgauffin
  • 99,844
  • 45
  • 235
  • 372
Vladimir Rodchenko
  • 1,052
  • 15
  • 25
  • 1
    possible duplicate of [Autofac - The request lifetime scope cannot be created because the HttpContext is not available - due to async code?](http://stackoverflow.com/questions/21804857/autofac-the-request-lifetime-scope-cannot-be-created-because-the-httpcontext-i) – jgauffin Jun 11 '14 at 14:54
  • This is not the same, I'm not using WebApi. – Vladimir Rodchenko Jun 13 '14 at 12:22
  • It's the same. Both WebApi and MVC runs in the ASP.NET pipeline. The HttpContext is the same. – jgauffin Jun 13 '14 at 12:35

1 Answers1

0

Hi I know that issue was solved after changes in Autofac.MVC5. In my case issue was because SessionProvider had initialization before first request and I think that was the issue. For now code works fine.

Vladimir Rodchenko
  • 1,052
  • 15
  • 25