Reputation: 10974
On the page Non-DI aware scenarios for Data Protection in ASP.NET Core I find the code that is intended to be a console application.
It is unexpected for me because console application references to ASP.NET Core library:
using Microsoft.AspNetCore.DataProtection;
When I tried to run it, I expectedly got an error message about missing assembly.
I asked Microsoft about this https://github.com/dotnet/AspNetCore.Docs/issues/17098. But I just got the come-off answer, I just got the reference to the page which is upper in the content: https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/introduction?view=aspnetcore-3.1#package-layout
When I run the code in the ASP.NET app, the following statement dataProtectionProvider.CreateProtector("Program.No-DI")
returned Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector
.
Which library contains KeyRingBasedDataProtector
?
I included the package https://www.nuget.org/packages/Microsoft.AspNetCore.DataProtection.Abstractions/, but it expectedly does not contain implementation.
In general, are ASP.NET libraries are suitable to use in console applications?
After all, how to run the code from the page Non-DI aware scenarios for Data Protection in ASP.NET Core?
Upvotes: 3
Views: 1350
Reputation: 10974
I included 3 packages to the console project:
This makes the console project working.
Upvotes: 4