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 am currently in need of a way to get a page id from a Url. I have found plenty of old topics relating to this issue, but none that provided an answer that seemed to work for me.
If I've got this Url: /sample/url/node/ the only way I could find to fetch the associated node's id would be to do something like:
However, something tells me that I'm probably over complicating it.
Any help would be very much appreciated!
You can use umbraco.uQuery.
Node node = uQuery.GetNodeByUrl("/home.aspx");
Look out when you want to use it in Umbraco 6.2.6. My website is stoping when I call this method.
If you're using Umbraco 4.11 or later, there are a new set of APIs that allow you to retrieve strongly-typed content (as opposed to dynamic - which can be frustrating when trying to evaluate types when debugging).
UmbracoContext.Current.ContentCache.GetByRoute(string url) should do what you want.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted