Base solution for your next web application
Open Closed

Registering services explicitly. #4436


User avatar
0
sparkyjr created

Is there any way I can register my services explicitly like this in the aspnet zero template. builder.RegisterType<ExampleService>().As<IExampleService>(); (done using Autofac)

Another query is why is GetRecentlyUsedLinkedUsers method getting called more often between 2 - 3 requests?

Also can I get preview of AspNet Zero source code? I have a paid subscription.


3 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Is there any way I can register my services explicitly like this in the aspnet zero template. builder.RegisterType<ExampleService>().As<IExampleService>(); (done using Autofac)

    From the Dependency Injection documentation's Custom/Direct Registration section:

    IocManager.Register<IExampleService, ExampleService>(DependencyLifeStyle.Transient);
    

    Do the above in the PreInitialize method of your module.

    Also can I get preview of AspNet Zero source code? I have a paid subscription.

    You need to login with your GitHub account to access the private repo. You can invite yourself here: <a class="postlink" href="https://aspnetzero.com/LicenseManagement">https://aspnetzero.com/LicenseManagement</a>

  • User Avatar
    0
    sparkyjr created

    Thanks for answering two of my questions. But I am still not sure as to what the method GetRecentlyUsedLinkedUsers does.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @sparkyjr,

    AspNet Zero has a user account linking feature. If you have more than one user, you can link all users to each other and you can easily login as another user, see <a class="postlink" href="https://aspnetzero.com/Documents/Development-Guide-Angular#linked-accounts">https://aspnetzero.com/Documents/Develo ... d-accounts</a>.

    GetRecentlyUsedLinkedUsers method returns last 3 linked user of current logged in user. If you are using angular 5 version, it is called 2 times (first one is for angular check, second one is for retrieving data), this is the default behaviour of angular. But if it is called more than 2 times, there might be a problem.