/// <summary>
        /// Gets the node Id by URL.
        /// </summary>
        /// <param name="url">The URL to get the XML node from.</param>
        /// <returns>Returns the node Id.</returns>
        /// <remarks>
        /// <para>Thanks to Jonas Eriksson http://our.umbraco.org/member/4853 </para>
        /// <para>Just runs lookups to find the document, does not follow internal redirects, 404 handlers,
        /// page access verification, wildcard domains -- nothing.</para>
        /// </remarks>
        public static int GetNodeIdByUrl(string url)
        {
            var uri = new Uri(url, UriKind.RelativeOrAbsolute);

            if (!uri.IsAbsoluteUri)
            {
                uri = uri.MakeAbsolute(Umbraco.Web.UmbracoContext.Current.CleanedUmbracoUrl);
            }
            uri = Umbraco.Web.UriUtility.UriToUmbraco(uri);

            var pcr = new Umbraco.Web.Routing.PublishedContentRequest(uri, Umbraco.Web.UmbracoContext.Current.RoutingContext);

            // partially prepare the request: do _not_ follow redirects, handle 404, nothing - just find a content
            pcr.Engine.FindDomain();
            pcr.Engine.FindPublishedContent();
            return(pcr.HasPublishedContent ? pcr.PublishedContent.Id : uQuery.RootNodeId);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the node Id by URL.
        /// </summary>
        /// <param name="url">The URL to get the XML node from.</param>
        /// <returns>Returns the node Id.</returns>
        /// <remarks>
        /// <para>Thanks to Jonas Eriksson http://our.umbraco.org/member/4853 </para>
        /// <para>Just runs lookups to find the document, does not follow internal redirects, 404 handlers,
        /// page access verification, wildcard domains -- nothing.</para>
        /// </remarks>
        public static int GetNodeIdByUrl(string url)
        {
            var uri = new Uri(url, UriKind.RelativeOrAbsolute);

            if (!uri.IsAbsoluteUri)
            {
                uri = uri.MakeAbsolute(Umbraco.Web.UmbracoContext.Current.CleanedUmbracoUrl);
            }
            uri = Umbraco.Web.UriUtility.UriToUmbraco(uri);

            var docreq  = new Umbraco.Web.Routing.PublishedContentRequest(uri, Umbraco.Web.UmbracoContext.Current.RoutingContext);
            var builder = new Umbraco.Web.Routing.PublishedContentRequestBuilder(docreq);

            builder.LookupDomain();
            builder.LookupDocument1();             // will _not_ follow redirects, handle 404, nothing - just run lookups
            return(docreq.HasNode ? docreq.DocumentId : uQuery.RootNodeId);
        }
Exemplo n.º 3
0
		/// <summary>
		/// Gets the node Id by URL.
		/// </summary>
		/// <param name="url">The URL to get the XML node from.</param>
		/// <returns>Returns the node Id.</returns>
		/// <remarks>
		/// Thanks to Jonas Eriksson http://our.umbraco.org/member/4853
		/// </remarks>
		public static int GetNodeIdByUrl(string url)
		{
			var uri = new Uri(url, UriKind.RelativeOrAbsolute);
			if (!uri.IsAbsoluteUri)
				uri = uri.MakeAbsolute(Umbraco.Web.UmbracoContext.Current.CleanedUmbracoUrl);
			uri = Umbraco.Web.UriUtility.UriToUmbraco(uri);

			var docreq = new Umbraco.Web.Routing.PublishedContentRequest(uri, Umbraco.Web.UmbracoContext.Current.RoutingContext);
			var builder = new Umbraco.Web.Routing.PublishedContentRequestBuilder(docreq);
			builder.LookupDomain();
			builder.LookupDocument();
			return docreq.HasNode ? docreq.DocumentId : uQuery.RootNodeId;
		}
Exemplo n.º 4
0
		/// <summary>
		/// Gets the node Id by URL.
		/// </summary>
		/// <param name="url">The URL to get the XML node from.</param>
		/// <returns>Returns the node Id.</returns>
		/// <remarks>
		/// <para>Thanks to Jonas Eriksson http://our.umbraco.org/member/4853 </para>
		/// <para>Just runs lookups to find the document, does not follow internal redirects, 404 handlers,
		/// page access verification, wildcard domains -- nothing.</para>
		/// </remarks>
		public static int GetNodeIdByUrl(string url)
		{
			var uri = new Uri(url, UriKind.RelativeOrAbsolute);
			if (!uri.IsAbsoluteUri)
				uri = uri.MakeAbsolute(Umbraco.Web.UmbracoContext.Current.CleanedUmbracoUrl);
			uri = Umbraco.Web.UriUtility.UriToUmbraco(uri);

			var pcr = new Umbraco.Web.Routing.PublishedContentRequest(uri, Umbraco.Web.UmbracoContext.Current.RoutingContext);
			// partially prepare the request: do _not_ follow redirects, handle 404, nothing - just find a content
			pcr.Engine.FindDomain();
			pcr.Engine.FindPublishedContent();
			return pcr.HasPublishedContent ? pcr.PublishedContent.Id : uQuery.RootNodeId;
		}