JasperFx / alba

Easy integration testing for ASP.NET Core applications
https://jasperfx.github.io/alba
Apache License 2.0
405 stars 39 forks source link

Why the container lifetime difference between AlbaHost ctor and task based #144

Closed goldenc closed 1 year ago

goldenc commented 1 year ago

when using the ctor IHttpContextAccessor is regitered as a singleton https://github.com/JasperFx/alba/blob/master/src/Alba/AlbaHost.cs#L65

when using the For task based api its registered as scoped https://github.com/JasperFx/alba/blob/master/src/Alba/AlbaHost.cs#L290

When trying to switch I'm now getting errors like Cannot consume scoped service 'Microsoft.AspNetCore.Http.IHttpContextAccessor' from singleton ...

Why don't they have the same lifetime ?

Hawxy commented 1 year ago

Good spot, will fix this now.