CmsContext.IsRequestCrawler 4.x equivalent

Posted by Community Admin on 04-Aug-2018 15:10

CmsContext.IsRequestCrawler 4.x equivalent

All Replies

Posted by Community Admin on 11-May-2011 00:00

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

Posted by Community Admin on 13-May-2011 00:00

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)


You can use this piece of code inside your control:
protected override void Render(HtmlTextWriter writer)
    var indexRenderMode = this.GetIndexRenderMode();
    if (indexRenderMode == IndexRenderModes.Normal)
    
        base.Render(writer);
            


Regards,
Ivan Pelovski
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed