Hi,
I need to get current node in external project where Node.GetCurrent is not working (null exception). So my idea is to get node id from request URL and I have app.Context.Items["umbOriginalUrl"] which is a same as Node.NiceUrl. My question is how can I get node id from URL?
I tried this (below) but node is always null and the urlName from xpath exist in umbraco.content.Instance.XmlContent.
int GetNodeIdFromUrl(String url)
{
Int32 nodeId = -1;
String xpath = umbraco.requestHandler.CreateXPathQuery(url, false);
if (!String.IsNullOrEmpty(xpath))
{
System.Xml.XmlNode node = umbraco.content.Instance.XmlContent.SelectSingleNode(xpath);
if ((node != null) && (node.Attributes != null))
{
Int32.TryParse(node.Attributes["id"].Value, out nodeId);
}
}
return nodeId;
}
Node Id from app.Context.Items["umbOriginalUrl"]
Hi, I need to get current node in external project where Node.GetCurrent is not working (null exception). So my idea is to get node id from request URL and I have app.Context.Items["umbOriginalUrl"] which is a same as Node.NiceUrl. My question is how can I get node id from URL? I tried this (below) but node is always null and the urlName from xpath exist in umbraco.content.Instance.XmlContent.
is working on a reply...