I have been using dependency injection inside a constructor which has been working great. I have recently learned of the [Inject] attribute, but cannot seem to get it to work. Maybe it's not compatible or perhaps I am misusing it.
Registering it as a service in Startup.cs:
services.AddScoped<IUserProfileService, UserProfileService>();
Using it as a property with the [Inject] attribute:
[Microsoft.AspNetCore.Components.Inject]
private IUserProfileService _UserProfileService { get; set; }
When _UserProfileService is called upon, it has not been initialized and is still null. If I switch back to injecting it in the constructor, it works. Am I misusing the attribute or is it simply not possible?
ASP.Net Core 3.1, using Blazor