Blazor DI works differently in .razor and business class RRS feed

  • Question

  • Hi there
    In my Blazor server application I can easily instantiate the class, say, DAL class in .razor part:

        @page "/"
        @inject DAL.DALClass dal
    and use it in my @code{} scope.

    But if I try to instantiate it in my domain logic class like

        public class ServerDesktopDTO : DesktopDTO
                protected DAL.DALClass dal { get; set; }
    dal is always null. 
    Why it works differently?
    How to inject it to my class using the [Inject] attribute and DI container? 
    Thursday, July 23, 2020 2:28 PM