I am new to the ASP.Net framework, and I am currently struggling to understand how to manage lifetimes of objects.
In a more specific case I am currently facing a problem in my application:
I want to have a class starting with my application, which should run in the background and do some work which results in some data my application controllers are working with later on.
I would therefore try to create this class' object in my Global.asax.cs
, so it can start and run as soon as my application is running as well.
However, how can I pass this instance to controllers which might get called later on then?
Currently, my only idea would be to make my data-collection class static
, which I am not really happy with, as I would like to avoid static classes as much as possible.
Is there any solution to this?