CmsContext.IsRequestCrawler 4.x equivalent
Good Morning,
We are currently in the process of our 4.x upgrade and are updating our custom usercontrols. For many of our controls we wrap the functionality in a !CmsContext.IsRequestCrawler(this.Context) check. We've found that without this, the search index in sitefinity takes a very long time as the controls do not load correctly when the crawler hits them and then has to wait while the error is generated. By disabling them for the search index, everything runs much smoother.
We've been reviewing the 4.x api, but cannot find the equivalent method to check for crawler. Any suggestions on where to look?
-Jon
Hi Jon Ingersoll,
There are several utility extension methods defined in System.Web.UI.ControlExtensions class and are used throughout Sitefinity. The method you can use is:
/// <summary>
/// Determines whether this control is rendered by the search engine (and this has to render partially/differently)
/// </summary>
/// <param name="control">Control to test</param>
/// <returns>True if the control should take special action during the rendering stage while being indexed, or false otherwise</returns>
public
static
IndexRenderModes GetIndexRenderMode(
this
Control control)
protected
override
void
Render(HtmlTextWriter writer)
var indexRenderMode =
this
.GetIndexRenderMode();
if
(indexRenderMode == IndexRenderModes.Normal)
base
.Render(writer);