I have the function that try to read umbracocontext: enter image description here
The problem is that even if I use the UmbracoContextAccessor in the SitemapController during a debug session (I'm using Immediate Window) it says that "it wasn't able to get an UmbracoContext" like the screen before.
Sitemap with custom controller
Hi,
I'm trying to create a custom controller with a custom route but I can't get the Umbraco Context.
This controller must render the sitemap of my website.
This is how I register the route
and this is the controller:
In the ActionResult GetSitemapIndex I can't access the UmbracoContext:
What am I doing wrong? I hope the question is specific enough.
Hi Francesco,
You already have the UmbracoContext passed in using DI, you just need to assign it to a local variable
Then in the constructor just assign it
Thank you for your help!
Unfortunately it does not work, any other ideas?
Hi,
What is ISitemapService ? It is that that is erroring, I have not come across this service in Umbraco.
It's a custom service written by me, and it use another class that return false in this if statement
Ok thanks for clarifying, so it is this service that is not getting an umbraco context rather than your controller.
What does your service code look like?
My service is this: And in baseRepository:
I have the function that try to read umbracocontext: enter image description here
The problem is that even if I use the UmbracoContextAccessor in the SitemapController during a debug session (I'm using Immediate Window) it says that "it wasn't able to get an UmbracoContext" like the screen before.
is working on a reply...