SaaS CMS has officially launched! Learn more now.

Error loading page in CMS

Vote:
 

Hi,

I'm currently working on a site running EPiServer CMS 7 and Commerce 1 R3.

In this site there is a main menu which loads top level category nodes from the commerce catalog as main menu items. It uses the URL from the node's SEO tab as the URL for each menu item.
Whenever you click on a menu item the EcfCatalogHandler picks up the URL and a custom display template for the category is loaded which is defined in Commerce (Catalog Management->Templates).
This all seems to be working ok, except when the page is loaded in edit/preview mode in the CMS.
So whenever I open the CMS edit mode, and in the menu of the homepage for example I click on a menu item, the page (display template) is loaded and a episerver popup appears which says "Unable to connect to the web server. What would you like to do?".

When examining this in the browsers network page I see that the CMS is sending a GET request to 'http://someurl.local/episerver/shell/Stores/context/?url=http%3A%2F%2Fsomeurl.local%2FHuren.aspx&epiworkspaceactive=true&dojo.preventCache=1454508091125' which then returns a 404 status code.

The log gives me this:

System.Web.HttpException (0x80004005): Not found: http://someurl.local/Huren.aspx
  at EPiServer.Shell.UI.Rest.ContextStore.NotFound(Uri uri)
  at EPiServer.Shell.UI.Rest.ContextStore.QueryForUrl(Uri url)
  at lambda_method(Closure , ControllerBase , Object[] )
  at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
  at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.b__10()
  at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
  at EPiServer.Shell.Services.Rest.RestControllerBase.ExecuteCore()
  at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
  at EPiServer.Shell.Services.Rest.RestHttpHandler.ProcessRequest(HttpContextBase httpContext)
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Does anyone have any suggestions?

Thanks in advance.

Regards,

Robert

#143936
Feb 03, 2016 15:09
Vote:
 

Might help to check url in admin for the site under -manage websites. I got some weird problems when previewing sites that had wrong urls there.

#143944
Feb 03, 2016 15:49
Vote:
 

Thanks for your suggestion, the URL seems to be what it should be so I don't think that is the problem.

I've decompiled the EPiServer.Shell.UI.Rest.dll assembly and looked up the ContextStore.QueryForUrl method.
And it seems there is no IUriContextResolver that can resolve the URL (I think).
See the decompiled code here:

private RestResult QueryForUrl(Uri url)
{
	foreach (IUrlContextResolver current in this._urlResolvers)
	{
		ClientContextBase data;
		if (current.TryResolveUrl(url, out data))
		{
			return base.Rest(data);
		}
	}
	return ContextStore.NotFound(url);
}

 

#143974
Edited, Feb 04, 2016 9:04
Vote:
 

I don think proper edit mode support form commerce was introduced until 7.5.

#143996
Feb 04, 2016 11:44
Vote:
 

I see,

I've done a small experiment by creating a Context resolver.
This seems to get rid of the popup box and the call to context store now returns 200 ok status code.

I've created the context resolver as described here: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Framework/7/User-Interface/Context-Sensitive-Components/

[ServiceConfiguration(typeof(IUrlContextResolver))]
public class CommercePageContextResolver : IUrlContextResolver
{
    public bool TryResolveUrl(Uri url, out ClientContextBase instance)
    {
        instance = ResolveUrl(url);
        return instance != null;
    }

    private ClientContextBase ResolveUrl(Uri url)
    {
        StaticCatalogUriHandler handler = new StaticCatalogUriHandler();
        Uri processedUri = handler.BuildUri(url.ToString(), url.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase));
        if (processedUri == null)
        {
            return null;
        }

        return new CommercePageContext
        {
            PreviewUrl = processedUri.ToString(),
            RequestedUri = processedUri,
            Uri = processedUri,
            Data = null
        };
    }

    public int SortOrder { get; set; }
}

public class CommercePageContext : ClientContextBase
{
    public override string DataType { get; set; }
}

I don't think it even has to go through the StaticCatalogUriHandler.

#144007
Feb 04, 2016 12:50
Vote:
 

Looks like a nice workaround. Nice catch!

#144017
Edited, Feb 04, 2016 14:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.