D
D
Dmitry Gavrilenko2018-06-29 10:52:49
ASP.NET
Dmitry Gavrilenko, 2018-06-29 10:52:49

AutoFac WebAPI constructor not set?

Hello.
Interesting story with this AutoFac.
register MVC controllers:

builder.RegisterControllers(typeof(MvcApplication).Assembly);

everything works great!
Register WebApi controllers:
builder.RegisterApiControllers(typeof(MvcApplication).Assembly);
// или
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
// или
builder.RegisterApiControllers(typeof(MyWebApiController).Assembly);

I probably get the well-known error "a constructor without parameters is not specified for this object"
With RegisterApiControllers , I tried all the methods that I found. No, none of the controllers is in another assembly. All in one, in the Controllers folder.
By the way, I want to note that if there is RegisterControllers (which works) and add RegisterApiControllers there, then MVC controllers fall with the same error.
What can be wrong?
MVC 5
Autofac 4.8
Autofac.Integration.Mvc 4
Autofac.Integration.WebApi 4.2

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question