My ASP.NET MVC 3 application uses Ninject IoC container. One of controllers depends on a data provider, that needs to start caching potentially required stuff when the web site starts, not when the controller is created on request and data is needed right a way.
So for this, I need to ask Ninject to create a singleton scope instance of my dependency, that it will that feed on requests on site start.
How can I do this?
I would just performing whatever operation in global.asax on application started override that NinjectHttpApplication provides. If you are using a regular HttpApplicaiton (without the NinjectHttpApplication override) in your global.asax, then just use the regular HttpApplication_Start event to do your initialisation of the cache. Touching the IoC container in this context is acceptable as it is the composite root of your application. So I guess something like:
I dont really see any need for it to be more complicated than this… I could be wrong though.
If you can provide more detail about the provider, i can give a more specific suggestion.