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
I'm rebuidling a Umbraco project to work with V10 from an older V8 build.
in V8, from inside my API controller (a controller that inherist from UmbracoApiController)
I could do this:
Current.UmbracoContext.Content.GetByRoute(pageUrl);
I want to do the same thing in this V10 version, I want to find content by its page URL
Whats the best way to do this when using UmbracoApiController in V10?
Hi Ayo!
I belive you have to do a DI of IUmbracoContextAccessor . Something like this:
IUmbracoContextAccessor
public class FooApiController: UmbracoApiController { private IUmbracoContextAccessor _umbracoContextAccessor; public FooApiController: (IUmbracoContextAccessor umbracoContextAccessor) { _umbracoContextAccessor = umbracoContextAccessor; } public string Bar() { var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext(); return ""; } }
Hope this gets you on the right track!
//Johannes
Thanks Johannes Lantz - Perfect.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
How to access Current.UmbracoContext from inside UmbracoApiController V10
I'm rebuidling a Umbraco project to work with V10 from an older V8 build.
in V8, from inside my API controller (a controller that inherist from UmbracoApiController)
I could do this:
I want to do the same thing in this V10 version, I want to find content by its page URL
Whats the best way to do this when using UmbracoApiController in V10?
Hi Ayo!
I belive you have to do a DI of
IUmbracoContextAccessor
. Something like this:Hope this gets you on the right track!
//Johannes
Thanks Johannes Lantz - Perfect.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.