Try our conversational search powered by Generative AI!

Asynchronous calls b0rken in editmode


All our asynchronous calls like searchbox-autocomplete, menu expansion etc are broken when triggered from inside edit mode, since the URL is changed.

For instance, a normal call to the asynch submenu:


Will transform into this, when triggered in edit mode:


This request ends with a 404 and a sad face...

We're using MVC (love it!!!) and wondering if there may be some magic routing config that can help us handle these scenarios?

Jun 11, 2013 22:34

Bump! Are there any recommendations from Episerver in this matter? Surely there are more sites out there that use asynchronous calls that needs to be working in editmode?

Jun 25, 2013 21:46

We had the same issue today... What you need to do is force the URL to be the public-facing (non Edit Mode) URL.

Knowing this, you'll find this topic: which states there is a bug (#91931) that prevents this. This bug was fixed, but is not available until (hopefully) EPiServer 7.5 (see comments in

The current workaround is this code, which we put outside of the controller in a static class:

public static string GetPublicUrl(ContentReference contentLink, string language, RouteValueDictionary routeValues = null)
    RequestContext requestContext = new RequestContext();
    requestContext.RouteData = new RouteData();

    requestContext.RouteData.DataTokens.Add("contextmode", ContextMode.Default);

    if (routeValues == null)
        routeValues = new RouteValueDictionary();

    var urlResolver = new UrlResolver();
    var contextSaved = HttpContext.Current;
    HttpContext.Current = null;

    var url = urlResolver.GetVirtualPath(contentLink, language, routeValues, requestContext).GetUrl();

    HttpContext.Current = contextSaved;

    return url;


Jun 25, 2013 23:08
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.