Try our conversational search powered by Generative AI!

Use Glimpse with EPiServer 7 --> NullReferenceException

Vote:
 

We are trying to use Glimpse (http://getglimpse.com) with our EPiServer 7 CMS, but it consistently fails with a NullReferenceException in the PageUrl method inside the UrlExtensions class. With some help from .NET Reflector, I think I understand why:

  1. Glimpse generates Castle proxies for all the RouteCollection elements in the "Url" class.
  2. Inside UrlResolver.GetVirtualPath, EPiServer looks for RouteCollection elements of type "ContentRoute", but the check "r is ContentRoute" always fails because there are only Castle proxies there instead.

This is a real showstopper, since we depend heavily on PageUrl. Is there any way we can work around this?

#72633
Jun 25, 2013 9:50
Vote:
 

+1 the same here. What I found so far is that by adding Glimpse it augments all routes and replaces with it's own proxy classes for intercepting calls to routing. EPiServer (and UrlResolver in particular) seems that don't like this case. The root cause for this exception is following method:

UrlResolver.GetVirtualPath(ContentReference contentLink, string language, RouteValueDictionary routeValues, RequestContext requestContext)

    

What it doesn't like is fact that there is no route of type ContentRoute in the routing table:

foreach (RouteBase base2 in from r in this._routes
where (bool) (r is ContentRoute)
select r)
{
   ...
   if(...)
   {
       return virtualPath;
   }
}

return null;

    

And after returning null to the caller NullReferenceExpcetion occours in:

UrlExtensions.MapUrlFromRoute(RequestContext requestContext, RouteCollection routeCollection, string url)

    

Seems like patch from EPiServer should be awaited.

#72646
Jun 25, 2013 14:34
Vote:
 

Just forwarding if somebody will look for a solution here:

 

A workaround (thanks to @avanderhoorn!) is to add this to the "glimpse" section of web.config:

<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
      <tabs>
        <ignoredTypes>
          <add type="Glimpse.AspNet.Tab.Routes, Glimpse.AspNet"/>
        </ignoredTypes>
      </tabs>
    <inspectors>
        <ignoredTypes>
            <add type="Glimpse.AspNet.Inspector.RoutesInspector, Glimpse.AspNet"/>
            <add type="Glimpse.Mvc.Inspector.ModelBinderInspector, Glimpse.Mvc4"/>
        </ignoredTypes>
    </inspectors>
</glimpse>

    

This disables the two parts of Glimpse that break with EPiServer. As far as I can see, you still get the most useful parts available!

#72719
Jun 27, 2013 9:10
Vote:
 

Just realized that EpiServer CMS Find plugin does not function correctly as well.

 

Unable to cast object of type 'Castle.Proxies.IViewProxy_1' to type 'System.Web.Mvc.WebFormView'.

[InvalidCastException: Unable to cast object of type 'Castle.Proxies.IViewProxy_1' to type 'System.Web.Mvc.WebFormView'.]
   ASP.episerverfindembeddedresources_episerver_find_framework_dll_episerver_find_framework_ui_views_shared_index_master.__Render__control6(HtmlTextWriter __w, Control parameterContainer) in C:\Projects\Kolumbus\Main\Kolumbus.Web\EPiServerFindEmbeddedResources\EPiServer.Find.Framework.dll\EPiServer.Find.Framework.UI.Views.Shared.Index.Master:29
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   ASP.episerverfindembeddedresources_episerver_find_framework_dll_episerver_find_framework_ui_views_shared_module_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in C:\Projects\Kolumbus\Main\Kolumbus.Web\EPiServerFindEmbeddedResources\EPiServer.Find.Framework.dll\EPiServer.Find.Framework.UI.Views.Shared.Module.Master:46
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
   System.Web.UI.Page.Render(HtmlTextWriter writer) +40
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +65
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5363
#72916
Jul 02, 2013 22:28
Vote:
 

It works again when you turn Glimpse off in /glimpse.axd though so you can still use glimpse on your site. Just not on the Find admin views.

#77265
Nov 14, 2013 10:29
Vote:
 

I just had a chat with Anthony and he pointed out that actually there is a workaround for Find admin module:

<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
    <runtimePolicies>
      <uris>
        <add regex=".*/find.*"/>
      </uris>
    </runtimePolicies>
</glimpse>

    

This will backlisting everything under "find" location. More info under "URIs":

https://github.com/Glimpse/Glimpse/wiki/Configuration

 

#77407
Nov 18, 2013 19:00
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.