Service only works when injected in a View ChildAction?

We have this old servie:

		public MetaDataUtilities(MetaService metaService, LanguageService languageService, RequestModelAccessor requestModelAccessor, RouteRequestLookupInfoAccessor routeRequestLookupInfoAccessor)
			_metaService = metaService;
			_languageService = languageService;
			_routeRequestLookupInfoAccessor = routeRequestLookupInfoAccessor;
			_requestModel = requestModelAccessor.RequestModel;

That we inject into our HeadViewModelBuilder.

When the _headViewModelBuilder.Build() is called from the LayoutControllers ChildActions (“Head”) the _requestModel work just fine, but if i call the _headViewModelBuilder.Build() directly from the Home or Product controller the_requestModel is null.

I can rewrite our service to use: _requestModelAccessor.RequestModel insted, that works fine. But am just curius why, what are the different between injecting it in a ViewChildAction vs in a controller?

Litium version: 7.4

What is the lifetime of the MetaDataUtilities and the controllers?

The RequestModel is set by the RequestModelActionFilter and it may be that the controllers will be invoked in an order so the OnResultExecuted method is completed before the child action are executed. Add some breakpoints in the RequestModelActionFilter and see there if you can figure out why it is set to null before your expectation.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.