GetActualCurrentNode() Null When Re-Indexing
In our pages, we have several UserControls that we've created that call SiteMapBase.GetActualCurrentNode() when rendering. They use the node path to identify and pull content items from a custom module we've created, and then display some property information from those content items (mostly name/address information). This code works just fine both front-end and back-end. However, when we re-index the search index we've set up, GetActualCurrentNode() always returns null whenever the spider tries to load the control.
We need the content generated by these controls to be rendered and included when the pages are indexed. Is there a way around this?
The only way is to escape the code that uses GetActualCurrentNode, because in index mode it is null. With the current implementation if the index fails its stops, so all other pages won't be indexed.
if(page.Items["IsInIndexMode"] == null)
We are making changes in the API for Q2 which will catch the error internally, log it and the index keep working.
the Telerik team
Thanks for the reply.
We've dealt with the error by coding around it, as you've said. Still, this means that no content rendered by controls that depend upon GetActualCurrentNode() can ever be indexed by the search. It would seem that this is could be a pretty serious drawback for developers creating custom modules and controls that tie pages to custom content together.
For example, we have a custom module that stores restaurant information (name, location, hours of operation, contact info, etc), and have pages in the site structure for each. Usercontrols figure out which page node we're looking at based on GetActualCurrentNode(), load the correct restaurant from our module based on the node path, and render all that info from the module directly to the page. Unfortunately, the limitation you've described with GetActualCurrentNode() means that none of that info will ever be rendered for the search crawler to index it.
We'll keep looking for workarounds. Any chance you can get GetActualCurrentNode() working in index mode in a future release?
The crawler gets all HTML from the page, so there should not be not indexed data. If you have exposed a pages on which your custom module data is stored then, it will be indexed. After refactoring the API for Q2 you will be able to crate a custom pipe for your modules, so you will be able to control what the index will include.
the Telerik team