I'm trying to create a simple route for specific content. The content is typically located deep in the hierarchy and the url is not straight forward. My intial idea was to create a partial routing for this content. It works except for one thing: When dragging content into an XhtmlString the links are created using the partial routing for some cases, for instance using drag and drop.
I test for PageEditing.PageIsInEditMode and return null in GetPartialVirtualPath, but this is not enough. It seems like the EPiServer client code performs url routing without specifying that it's in edit mode.
The question is; how can I make sure that the partial routing is only used for page viewing? I've come up with this solution so far, but I'm not entirly satisfied. In addition to testing PageIsInEditMode is use the following test:
public static bool UsedFromEditMode(this RequestContext instance) { // Default is "user" mode if (instance.GetContextMode() != ContextMode.Default) { return true; }
// All calls from EPiServer API are from edit mode if (instance.HttpContext.Request.Url?.Segments.Any(s => string.Equals(s, "EPiServer/", StringComparison.OrdinalIgnoreCase)) ?? false) { return true; }
I'm trying to create a simple route for specific content. The content is typically located deep in the hierarchy and the url is not straight forward. My intial idea was to create a partial routing for this content. It works except for one thing: When dragging content into an XhtmlString the links are created using the partial routing for some cases, for instance using drag and drop.
I test for PageEditing.PageIsInEditMode and return null in GetPartialVirtualPath, but this is not enough. It seems like the EPiServer client code performs url routing without specifying that it's in edit mode.
The question is; how can I make sure that the partial routing is only used for page viewing? I've come up with this solution so far, but I'm not entirly satisfied. In addition to testing PageIsInEditMode is use the following test:
public static bool UsedFromEditMode(this RequestContext instance)
{
// Default is "user" mode
if (instance.GetContextMode() != ContextMode.Default)
{
return true;
}
// All calls from EPiServer API are from edit mode
if (instance.HttpContext.Request.Url?.Segments.Any(s => string.Equals(s, "EPiServer/", StringComparison.OrdinalIgnoreCase)) ?? false)
{
return true;
}
return false;
}
Has anybody else solved this?
Regards,
Bjørn Terje Svennes