Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hey All,
Does anyone know how to compose services and helpers inside custom classes or razor views without using dependency injection.
As a reminder the old way we used to do that i Umbraco 8 was like the following..
@using Current = Umbraco.Web.Composing.Current IBlogHelper _blogHelper = Current.Factory.GetInstance
Regards
David
You cannot.. (and should not :P)
Dependency injection (DI) is supported in the web framework, so in views you can just do something like
@inject IBlogHelper _blogHelper
DI is also supported for filters etc.
Thanks Bjarke.
I will give this a go. Its great that these now get injected into razor views like this now.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco 9 Composing Inside Custom Classes and Razor without Dependency Injection
Hey All,
Does anyone know how to compose services and helpers inside custom classes or razor views without using dependency injection.
As a reminder the old way we used to do that i Umbraco 8 was like the following..
@using Current = Umbraco.Web.Composing.Current IBlogHelper _blogHelper = Current.Factory.GetInstance
Regards
David
You cannot.. (and should not :P)
Dependency injection (DI) is supported in the web framework, so in views you can just do something like
DI is also supported for filters etc.
Thanks Bjarke.
I will give this a go. Its great that these now get injected into razor views like this now.
is working on a reply...