Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This module requires that the HttpApplication implements IContainerProviderAccessor

Hi I want to use Autofac in my asp.net mvc appliation and here is the code I have in global.asxc file :

 protected void Application_Start()
    {
        ....

        var builder = new ContainerBuilder();
        builder.RegisterControllers(Assembly.GetExecutingAssembly());

        IContainer container = builder.Build();

        DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

    }

but when I run the project, I see this error :

This module requires that the HttpApplication (Global Application Class) implements IContainerProviderAccessor

what is wrong ?

like image 791
Babak Fakhriloo Avatar asked Jan 20 '23 18:01

Babak Fakhriloo


1 Answers

I had the same problem as the OP, but my solution was different.

From here:

Remove Old Items

  • Remove IContainerProviderAccessor interface from Global.asax. This implementation is no longer used by ASP.NET MVC integration.
  • Remove references to the AutofacControllerFactory. The new MVC integration uses the MVC DependencyResolver class for integration instead.
  • Remove ASP.NET Autofac HTTP module configurations. Previously there were some Autofac ContainerDisposal and PropertyInjection modules required in your web.config. These should be removed.
like image 127
Jim G. Avatar answered Apr 27 '23 00:04

Jim G.