1

Closed

Most Recent tab under View error (when no records have been created)

description

After enabling the module, the Admin dashboard shows Person List Dashboard > Create and View.

When you click on View (without having created anything), this error pops up under "Most Recent One" tab:

Oops. Something went wrong ... sorry

An unhandled exception has occurred and the request was terminated. Please refresh the page. If the error persists, go back
Sequence contains no elements
System.InvalidOperationException: Sequence contains no elements at System.Linq.Enumerable.First[TSource](IEnumerable1 source) at OrchardHUN.TrainingDemo.Controllers.ContentsAdminController.LatestPersonList() at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.<InvokeActionMethodWithFilters>b__10() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation)
Closed Mar 6, 2013 at 4:43 PM by Piedone
Fixed.

comments

Piedone wrote Mar 6, 2013 at 4:34 PM

Well, it says on ln. 187 of ContentsAdminController that
                // We here assume that there is at least one PersonList item. Otherwise we'd use FirstOrDefault() and check for null, but you
                // created some PersonList items, didn't you?
:-)

Piedone wrote Mar 6, 2013 at 4:43 PM

Fixed in changeset 0a1b9269dd1f

DinoStar wrote Mar 7, 2013 at 6:01 AM

My mistake. I was recalling PersonController which created some records but didn't actually have any ActionResults.