Martin Davies
Martin Davies

Reputation: 4456

Sitecore pipeline processor messing up the CMS

I have a pipeline processor which works as expected on the site, but causes havoc when you go in to the CMS.

What is the proper way to determine if the request is to the CMS? Preferably I'd like something a little more robust than checking to see if the URL contains "/sitecore/".

Upvotes: 0

Views: 453

Answers (2)

nickwesselman
nickwesselman

Reputation: 6890

Site context is a great way to do this. You can use standard Sitecore configuration factory approaches to feed in the site names that should utilize the extension, then ignore others, including "shell."

c.f. https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/the-sitecore-asp-net-cms-configuration-factory

Upvotes: 5

Andy Uzick
Andy Uzick

Reputation: 81

You can exit gracefully if you are in the "shell" site...

if (Sitecore.Context.Site.Name.Equals("shell", StringComparison.InvariantCultureIgnoreCase))
{
    // Exit here if we're avoiding the sitecore shell altogether
    return;
}

It depends on what it is about the circumstances that is causing your code to blow up. You can check the page mode to avoid problem modes...

if (Sitecore.Context.PageMode.IsPageEditorEditing)
{
    // Exit here if we're avoiding someone editing the page.
    return;
}

Upvotes: 3

Related Questions