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
Hi,
I'm trying to get the url of an IPublishedContent with the UmbracoHelper inside an UmbracoApiController.
the query:
UmbracoHelper uh = new UmbracoHelper(base.UmbracoContext); var foundOffices = uh.TypedContentAtXPath("//Office[zip= '" + cityZip + "']");
I get results for foundOffices but when I try to say
foreach(var item in foundOffices) { Log(item.Url); }
It says:
Cannot resolve a Url for a content item with a null UmbracoContext.Current reference
Any suggestions?
Maybe try this to create the UmbracoHelper:
var uh = new UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
Jeroen
Still getting the error but not always.
Could this be an internal cache error?
Hi, What are you trying to achive with this? Maybe there is another way :). Thanks, Charlie
UmbracoHelper uh =newUmbracoHelper(base.UmbracoContext);var foundOffices = uh.TypedContentAtXPath("//Office[zip= '"+ cityZip +"']");
What does it look like I'm trying to achieve?
I want to get the url of a document where the zip property is whatever is in cityZip.
Well if you wanted help the reply was
Good luck :). Charlie
Ok, the answer to the problem is calling the
Umbraco.Web.UmbracoContext.EnsureContext()
Method before trying to get the url.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get Url with UmbracoHelper
Hi,
I'm trying to get the url of an IPublishedContent with the UmbracoHelper inside an UmbracoApiController.
the query:
I get results for foundOffices but when I try to say
It says:
Any suggestions?
Maybe try this to create the UmbracoHelper:
Jeroen
Still getting the error but not always.
Could this be an internal cache error?
Hi, What are you trying to achive with this? Maybe there is another way :). Thanks, Charlie
What does it look like I'm trying to achieve?
I want to get the url of a document where the zip property is whatever is in cityZip.
Well if you wanted help the reply was
I want to get the url of a document where the zip property is whatever is in cityZip.
Good luck :). Charlie
Ok, the answer to the problem is calling the
Method before trying to get the url.
is working on a reply...