Failed to create SitecoreContext While making ajax call to a contrlloer method which is derived from glasscontroller class

466 views
Skip to first unread message

santanu

unread,
Feb 2, 2015, 4:59:50 AM2/2/15
to glasssite...@googlegroups.com
Hi,
When there is an ajax call made to a controller action method and the Controller is derived from Glass controller, I am getting below exception in log.

Sitecore.Diagnostics.Log.Error(:0)ocation ERROR Failed to create SitecoreContext
Exception: System.InvalidOperationException
Message: Attempt to retrieve context object of type 'Sitecore.Mvc.Presentation.RenderingContext' from empty stack.
Source: Sitecore.Mvc
   at Sitecore.Mvc.Common.ContextService.Peek[T]()
   at Glass.Mapper.Sc.Web.Mvc.GlassController..ctor()

I have defined the rout for ajax calls to sitecore mvc controller as below

            routes.MapRoute(
               name: "Client", // Route name
                url: "client/{controller}/{action}/{id}", // URL with parameters
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

Please suggest what can be done not to get this exception while making the Ajax call to sitecore MVC controller action method where the controller class is derived from GlassController class ?

Thanks,
Santanu
Reply all
Reply to author
Forward
0 new messages