Layout designer issue

Topics: Troubleshooting
Apr 18 at 2:13 PM
Hi all,

I have version 1.10 and I have created a content type with a Layout part attached to it - I went for that over the Body part so that I could add in Shapes - for example the current user's name so the page could say 'Hello Bob, welcome to...'

But when I try to save I get an error (below), I tried this in both IE 11 and in Chrome, the only difference in Chrome being that I momentarily saw a message informing me 'Orchard is temporarily unavailable as a change in configuration requires a restart. A simple page refresh usually solves this issue.'
2016-04-18 13:26:16,252 [46] Orchard.Exceptions.DefaultExceptionPolicy - Default - An unexpected exception was caught [http://localhost/Orchard.Web/Admin/Layouts/Element/Update?session=648e440b-95e1-4f25-9f27-e81030e8ffc7]
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.Layouts.Controllers.ElementController.Update(String session)
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   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.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
Any thoughts on this?
Apr 18 at 4:01 PM
quick update - not fixed it, but I know a little more about what is happening now.

In both the update and edit methods of the Element Controller in Orchard.Layouts it tries to get the session state
 var sessionState = _objectStore.Get<ElementSessionState>(session);
session is a string that is passed into it - I can see there is a guid value in there when I debug in Visual Studio, but that call returns a null value, so that when it calls the next line
var contentId = sessionState.ContentId;
it fails because sessionState is null
Developer
Apr 18 at 4:34 PM
Edited Apr 18 at 4:34 PM
This error occurs if SessionState gets lost for whatever reason. You mentioned the message "Orchard is temporary unavailable..." which means it is re-compiling in the background, so your session will definitely have been lost. The only work around this situation is to close the element editor dialog and try again. This is a know issue and is reported on GitHub (regarding the session state issue).
Apr 18 at 4:58 PM
Hmmmm.... Tried that already. If I go to edit a page that I've already created, when I see the error on screen, there is no option to close the dialog - my only way out seems to be the browser's back button, which means any changes I've tried to make would be lost :(

With a new page it seems to stick in a loop of showing my that error - whether I try the save button again, or pressing cancel :(

Is there a thread for this on github I can look at, might give me a few hints to try and figure this out?
Developer
Apr 18 at 5:14 PM
So you;re saying you are getting this issue all the time? That is definitely not normal, and an unknown issue. This is the issue I was referring to: https://github.com/OrchardCMS/Orchard/issues/5821
Apr 19 at 4:03 PM
I've just tried it again today...

Created a new page using my type, dragged a text box onto the layout - got the IE 'Page needs to refresh, careful if you are making a purchase' warning twice. Clicked on the button in the corner to pop out the variable list, selected {User.Name}, typed in some text, hit the save button. IE gives me the 'page is going to refresh, careful if you are making a purchase' box again, I tell it to retry.

I get the 'Oops' message again. Pressing save does nothing, pressing cancel closes the window and returns me to the empty layout screen.

Error log contains the following
2016-04-19 15:55:11,493 [49] Orchard.Exceptions.DefaultExceptionPolicy - Default - An unexpected exception was caught [http://localhost/Orchard.Web/Admin/Layouts/Element/Update?session=129f2a23-319d-4053-a7f2-9b0aa1f222ba]
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.Layouts.Controllers.ElementController.Update(String session)
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   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.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
So I save the page as is, with nothing in the layout control, and go to the content list, with the aim of selecting the item, and editing it.

I go to layout, again drag the text on, the IE 'Page needs to refresh, careful if you are making a purchase' box appears once, I select the same variable and hit save. IE again gives me the warning, I press retry, then see the 'Ooops' message. Save does nothing, Cancel closes the window. Repeating the process is exactly the same, it does not matter if I have one of the variables in or not.
Apr 19 at 4:36 PM
Update - If I try to create a new Page, using the page content type, the moment I drag the text control onto the layout it gives me the IE 'Page needs to refresh, careful if you are making a purchase' box, then the 'Ooops' message and there is no way to close the dialog.
Apr 20 at 10:01 AM
Edited Apr 20 at 1:43 PM
A further update - I tried a clean install of Orchard, this time using SQL CE instead of SQL Server 2008 R2.

The layout designer worked - I used the page content type that comes 'out of the box' and was able to drag text on there, put something in and view the page. So it looks to me like the issue is with using full blown SQL server.

Interesting to note putting 'Hello {User.Name}' in the text does not seem to give you a page that renders 'Hello Bob' to the user - I literally got 'Hello {User.Name}' when viewing the page
  • Update - turns out SQL is a red herring - it looks like it is something to do with using IIS that causes errors, IIS Express and it doesn't care what the database is. Hope that helps anyone else
Developer
Apr 22 at 9:35 AM
Regarding the token issue, which element are you using? Html? If so, make sure to enable the Tokens Html Filter feature.
Apr 22 at 10:09 AM
And that worked, always the simple things....