Copied to clipboard

Flag this post as spam?

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


  • danieljjacob 2 posts 22 karma points
    Feb 25, 2020 @ 06:17
    danieljjacob
    0

    Server Error in '/' Application.

    Hi Guys,

    Site was working perfectly fine up until yesterday when this new error started appearing after login.

    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 matching element
    
    Source Error:
    
    
    Line 61:     var allclient = new List<ClientViewModel>();
    Line 62: 
    Line 63:     var clients = CmsTreeManager.GetClient();
    Line 64:     allclient.AddRange(clients.Select(client => new ClientViewModel
    Line 65:     {
    
    Source File: d:\home\site\wwwroot\Views\Orders.cshtml    Line: 63
    
    Stack Trace:
    
    
    [InvalidOperationException: Sequence contains no matching element]
       System.Linq.Enumerable.Single(IEnumerable`1 source, Func`2 predicate) +2795185
       CdmPrint.Helpers.CmsTreeManager.GetClient() +297
       ASP._Page_Views_Orders_cshtml.Execute() in d:\home\site\wwwroot\Views\Orders.cshtml:63
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198
       System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
       System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +235
       System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
       Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +113
       System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
    

    I'm not sure where to start looking to figure out what is causing this but the user has advised it occured after he was adding a new client in.

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Feb 25, 2020 @ 11:44
    Steve Morgan
    0

    If you look in the file \Views\Orders.cshtml

    Around line 63 you'll likely see a list of properties being set. One of the them is null (not set). I'd bet some money on it being an image or something "picked"... or could it be that this client doesn't have any orders (as I'm guessing that's what this page lists?).

    If you post the code in that file here can probably advise how to change it to "null check".

  • danieljjacob 2 posts 22 karma points
    Feb 25, 2020 @ 12:01
    danieljjacob
    0

    Hi, below is a snippet of orders.cshtml from the lines before and after 63 which is causing the errors.

    How would I go changing this to a null check, the page was working perfectly fine up until yesterday when the user advised they added a new client.

    //bool isBupaOffice = Session["isHeadOffice"] != null && bool.Parse(Session["isHeadOffice"].ToString());
    //bool isUser = Session["isStaff"] != null && bool.Parse(Session["isStaff"].ToString());
    int billingid = 0;
    var clientId = member.HasProperty("client") ? member.GetValue<int>("client") : 0;
    List<OfficeViewModel> alloffice = (List<OfficeViewModel>)HttpContext.Current.Cache["AllOffice" + clientId];
    if (isHeadOffice && alloffice == null)
    {
        alloffice = new List<OfficeViewModel>();
    
        var clientumbraco = member.GetValue<int>("client");
        var allmember = memberService.GetMembersByPropertyValue("client", clientumbraco);
    
        foreach (var m in allmember)
        {
            alloffice.Add(new OfficeViewModel
            {
                Name = m.Name,
                IsHeadOffice = m.HasProperty("isHeadOffice") ? m.GetValue<bool>("isHeadOffice") : false,
                MemberId = m.Id.ToString()
            });
        }
    
        alloffice = alloffice.OrderByDescending(c => c.IsHeadOffice).ToList();
    
        HttpContext.Current.Cache["AllOffice" + clientId] = alloffice;
    }
    
    var allclient = new List<ClientViewModel>();
    
    var clients = CmsTreeManager.GetClient();
    allclient.AddRange(clients.Select(client => new ClientViewModel
    {
        ClientId = client.Id,
        Name = client.Name
    }));
    
    
    DateTime date = DateTime.Now;
    
  • Steve Morgan 1346 posts 4453 karma points c-trib
    Feb 26, 2020 @ 09:41
    Steve Morgan
    0

    Hmm.. looking at that it looks like the call to CmsTreeManager.GetClient(); is returning null.

    I'd suggest you go carefully through this client setup and make sure that they have all the data set. And that they are a "member" of the correct groups etc. Without seeing the logic in GetClient it's hard to see.

    Do you have the source code? It would be worth debugging this if you can.

    Steve

Please Sign in or register to post replies

Write your reply to:

Draft