I made some tries without success. config.EnsureInitialized() is called before using the configurationobject in Startup but I get always the same error. I checked when EnsureInitialized is called and tried to move it in different places (module Initialize, PreInitialize, PostInitialize and in Startup) but the result is always the same.
I tryed with
public void Configuration(IAppBuilder app)
{
app.UseAbp();
// accept access tokens from identityserver and require a scope of 'api1'
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = "http://localhost:29169",
ValidationMode = ValidationMode.ValidationEndpoint,
RequiredScopes = new[] { "myapi" }
});
var config = Abp.Dependency.IocManager.Instance.Resolve<IAbpWebApiModuleConfiguration>().HttpConfiguration;
config.EnsureInitialized();
config.MapHttpAttributeRoutes();
app.UseWebApi(config);
}
But I got the same error, I tryed to move
config.EnsureInitialized();
in module initialization too but the same error still here. I have no more ideas how to solve this problem.
Many thanks but this doesn't resolve my problem. Using
var config = Abp.Dependency.IocManager.Instance.Resolve<IAbpWebApiModuleConfiguration>().HttpConfiguration;
in Startup give me this error:
The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup code after all other initialization code.
I finally unerstood the problem. In my project I'm using IdentityServer3 as external auth system, it uses Owin and require this in Startup::Configuration
public void Configuration(IAppBuilder app)
{
app.UseAbp();
// accept access tokens from identityserver and require a scope of 'api1'
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = "http://localhost:29169",
ValidationMode = ValidationMode.ValidationEndpoint,
RequiredScopes = new[] { "myapi" }
});
// configure web api
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
app.UseWebApi(config);
}
Looking at the code in <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web.Api/WebApi/Configuration/AbpWebApiModuleConfiguration.cs">https://github.com/aspnetboilerplate/as ... uration.cs</a> I see You use GlobalConfiguration.Configuration and this is the problem. Trying to remove the configuration in startup and app.UseWebConfig make Abp works but not IdentityServer integration.
Yes, my APi module is:
[DependsOn(typeof(AbpWebApiModule),
typeof(BusinessModule),
typeof(DataModule),
typeof(DataEfModule))]
public class ApiModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
Many thanks, now module Initialize is called as expected but I'm facing another problem. In my application I made a simple ApplicationService I'd like to inject in a ApiController (I don't want to use Dynamic Api Controllers). Trying to put some brakpoint in modules initialize methods i see all my services are correctly registered but I get an error like:
An error occurred when trying to create a controller of type 'UserController'. Make sure that the controller has a parameterless public constructor.
UserController is my ApiController, it receives the ApplicationService by constructor injection but there is something wrong because as You can see Abp can't inject the dependency. How can I check the problem? I tried to use ApiController and AbpApiController with the same result.
thanks Fabrizio
Hi, I'm trying to use Abp with a WebApi project using Owin. I made a simple module and in Startup class I call
app.UseAbp();
but Initialize of my module is never called. Module class is pretty simple
[DependsOn(typeof(DataEfUsersModule),
typeof(DataUsersModule),
typeof(BusinessUsersModule))]
public class EpAuthModule : AbpOwinModule
{
public override void PreInitialize()
{
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
And Configure method of Startup is also really simple:
public void Configuration(IAppBuilder app)
{
app.UseAbp();
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
app.UseWebApi(config);
}
Is there something wrong ?