Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:32:40+00:00 2026-06-10T18:32:40+00:00

I used the MVC integration from autofac like this: … var container = builder.Build();

  • 0

I used the MVC integration from autofac like this:

...
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

But now I want to recreate the solution with the new Web Api RTM.
And I want to use the new AutofacWebApiDependencyResolver class.

But if I do this with AutofacWebApiDependencyResolver i got this error:

The type Autofac.Integration.WebApi.AutofacWebApiDependencyResolver
does not appear to implement
Microsoft.Practices.ServiceLocation.IServiceLocator.

I read that i have to do this now for setting the resolver:

GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);

But if I set it with ‘=’, it is not set. Its still the DefaultResolver…

If I use the MVC AutofacDependencyResolver class again, it works.

Are were still problems with autofac and web api rtm? (the current integration is RC version)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:32:42+00:00Added an answer on June 10, 2026 at 6:32 pm

    ASP.Net Wep.API and ASP.NET MVC uses two different IDependencyResolver (because they designed the Wep.API to not depend on ASP.NET MVC) so you need to setup both:

    var container = builder.Build();
    DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
    GlobalConfiguration.Configuration.DependencyResolver = 
         new AutofacWebApiDependencyResolver(container);
    

    So the AutofacDependencyResolver is needed to inject decencies to regular MVC Controller derived controllers.

    And the AutofacWebApiDependencyResolver is needed to inject dependencies to the Web.API ApiController derived controllers.

    And don’t forget to register your Api controllers in your container builder with the call (it differs from usual builder.RegisterControllers method):

    builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Spring MVC, so I'm confused. I've used MVC in Struts, so
This piece of code used to work in MVC 1 but it does not
Has anyone used structuremap with the new DI features of asp.net mvc 3.0? If
I am using Autofac with ASP.NET MVC integration, all my controllers receive dependencies and
I have used spring MVC with JSP/JSTL for my previous application. I was going
MVC is used a number of popular frameworks. To name just a few, Ruby
Why is MODEL in ASP.NET MVC sometimes used as part of an application that
Please give me an example for MVC pattern used in Java SWING package ?
I am looking at some good templating systems to be used alongwith an MVC
I have been reading about MVP, MVVM and have used asp.net MVC in couple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.