I am using Umbraco API Controller and I'm trying to get the current page so that I can access the properties on in the controller. But Umbraco throws a "No current node" or a null exception when I use "Node.GetCurrent". I tried everything I found in the internet but throws the same error. However, If I use IPublishedContent currentPage = Umbraco.TypedContent(1079);, as you can see, I hard-coded the NodeId, I do find my page/Node. But I do not want to hard-code my page/nodeId because I need it to be dynamic.
Any help would be great.
Get Current Page/Node
Hi,
I am using Umbraco API Controller and I'm trying to get the current page so that I can access the properties on in the controller. But Umbraco throws a "No current node" or a null exception when I use "Node.GetCurrent". I tried everything I found in the internet but throws the same error. However, If I use IPublishedContent currentPage = Umbraco.TypedContent(1079);, as you can see, I hard-coded the NodeId, I do find my page/Node. But I do not want to hard-code my page/nodeId because I need it to be dynamic. Any help would be great.
Thanks.
Hi Luyolo,
I was thinking if you can do something like this:
Will this do what you are trying to archive.
Hope this helps,
/Dennis
Hi,
If you are using Surface Controller you can use:
If you are using api controller then its not possible - you need to send the id as part of the GET or POST and then use your method above, ie:
Hi Luke,
Im using the UmbracoApiController.
That is the problem I'm having? How to get that id?
Hi Luyolo,
What if you do something like this
Hope this helps,
/Dennis
Hi Dennis,
I tried that, but it does not work. That will work if I use "SurfaceController" but not when I use UmbracoApiController.
That is what I want to use and not
Thanks,
Luyolo
Also, 1 think I should mention. I am using angularjs to do call to my controller.
This is the exception I get
is working on a reply...