Can I call cascading parameters and/or injected services anywhere?

David Thielen
3,211
Reputation points
This seems to work but it may be because of where/how I'm using it (server side). In a random .cs file, not part of a page.razor.cs or similar file, I have the following:
[Inject] private ILogger<Register> Logger { get; set; } = default!;
[CascadingParameter] private Task<AuthenticationState> authenticationStateTask { get; set; } = default!;
and it works fine - I can use both. Is this valid to do in any code anywhere in the app once main() in program.cs has completed setup? Or is this something that will cause me problems and/or is limited to only certain uses?
thanks - dave
Developer technologies | .NET | Blazor
1,674 questions
Sign in to answer