Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • nathan 8 posts 28 karma points
    May 09, 2014 @ 15:54
    nathan
    0

    Sequence contains no elements

    In my setup I have a couple of "folder" document types whose only purpose is to help organize the site tree. These pages don't have any template assigned to them.  I noticed when navigating to them I end up getting the following error. I'm guessing I could create a template that would redirect to the home page or 404 page and assign it to these document types, but I was wondering if there was a more elegant way to fix this? 

    Server Error in '/' Application.

    Sequence contains no elements

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.InvalidOperationException: Sequence contains no elements

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace: 

    [InvalidOperationException: Sequence contains no elements]
       System.Linq.Enumerable.First(IEnumerable`1 source) +514
       umbraco.library.GetCurrentNotFoundPageId() +1070
       Umbraco.Web.Routing.ContentFinderByLegacy404.TryFindContent(PublishedContentRequest pcr) +80
       Umbraco.Web.Routing.ContentLastChanceFinderByNotFoundHandlers.HandlePageNotFound(PublishedContentRequest docRequest) +1242
       Umbraco.Web.Routing.ContentLastChanceFinderByNotFoundHandlers.TryFindContent(PublishedContentRequest docRequest) +16
       Umbraco.Web.Routing.PublishedContentRequestEngine.HandlePublishedContent() +482
       Umbraco.Web.Routing.PublishedContentRequestEngine.UpdateRequestOnMissingTemplate() +33
       Umbraco.Web.Routing.PublishedContentRequest.UpdateOnMissingTemplate() +28
       Umbraco.Web.Mvc.RenderRouteHandler.GetHandlerForRoute(RequestContext requestContext, PublishedContentRequest publishedContentRequest) +166
       System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +12761271
       Umbraco.Web.UmbracoModule.ProcessRequest(HttpContextBase httpContext) +568
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446

  • Amir 75 posts 224 karma points
    May 09, 2014 @ 16:03
    Amir
    1

    There are multiple solutions for this problem:

    1- If you want to have a 404 error page you only need to update your umbracoSetting.config file in your config directory

    <errors>
          <!-- the id of the page that should be shown if the page is not found -->
          <error404>---Your Error Page ID--</error404>
    </errors>

    2- you can have a property named i.e RedirectTo in you all pages i.e in properties tab, and in you top masterpage/ layout/ ... check whether this property has any value, if so navigate to the given address/node

     

     

  • nathan 8 posts 28 karma points
    May 09, 2014 @ 17:18
    nathan
    0

    Hi Amir,

    I'm not actually using the errors section of the umbracoSetting.config file because I have a custom 404 handler built as this is a multi-site installation.  My 404 page is working in all cases (including pages that are using the umbracoURLAlias property), except for the "folder" nodes that don't have a template assigned to them.  It sounds like your second solution is similar to what I was originally thinking, where I would just build out a new template for these "folder" nodes and have the template redirect to another page (like the 404 page). But, I was hoping to find out why the error was occurring in the first place as this seems like a bug (I get the .net error "Sequence contains no elements" if there is no template assigned to a node).

    Thanks,

    nathan

  • Amir 75 posts 224 karma points
    May 09, 2014 @ 17:35
    Amir
    0

    I dont believe that is a bug. Umbraco tries to render the page while no templates is assigned to this page. You should be able to see this error page while developing so you can find your best solution for it.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 09, 2014 @ 20:15
    Jan Skovgaard
    0

    Hi Nathan

    What version of Umbraco are you using?

    There was a bug that gave this error message in version 6.0.2 or something...and last week I even saw it on a 6.1.6 solution. I managed to fix it easily since I'm using CE SQL and had it in version control. When it happened to me I was trying to add a property to a document type.

    This search on google reveals more information https://www.google.dk/search?q=Sequence+contains+no+elements&oq=Sequence+contains+no+elements&aqs=chrome..69i57j0l5.468j0j4&sourceid=chrome&es_sm=119&ie=UTF-8#q=Sequence+contains+no+elements+umbraco+proworks

    Perhaps you could benefit from this blogpost by Proworks http://www.proworks.com/blog/2013/03/11/umbraco-602-upgrade-bug-solution/

    Hope this helps.

    /Jan

  • nathan 8 posts 28 karma points
    May 27, 2014 @ 14:12
    nathan
    0

    Hi Jan,

    After spending some more time looking around this seems to be a pretty common problem.  In any case I created a new template that would just redirect to my 404 page for these document types that aren't supposed to actually display a webpage, which seems to work well.  Thank you for the suggestions.

    Thanks,

    nathan

Please Sign in or register to post replies

Write your reply to:

Draft