Hello,
I want to use a regulard Web API 2 project instead of the self-hosted project generated by the template. So i added a new web api 2 project to solution. I added the packe abp.web.api. I added the module class and the dependency
[DependsOn(
typeof(TestDataModule),
typeof(TestApplicationModule),
typeof(AbpWebMvcModule),
typeof(AbpWebApiModule))]
public class TestApiModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
DynamicApiControllerBuilder
.ForAll<IApplicationService>(typeof(TestApplicationModule).Assembly, "app")
.Build();
Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer"));
}
}
But when I tried to call directly a service from the application project, I have 404 not found error. When I tried to call directly a controller, I have the error : "An error occurred when trying to create a controller of type 'WhateverController'. Make sure that the controller has a parameterless public constructor."
It seems like an error related to the IoC mechanism.
Am I missing something? thanx
2 Answer(s)
-
0
So, how did you bootstrap ABP? Are you sure that TestApiModule.Initialize method is running.
-
0
Hello,
Indeed, the Initialize method was never called. So I checked again and I compare the project to the one created by the template. It turns out that my application class wasn't implemented AbpWebApplication. It works now. Thanks