The sequence does not contain elements just inside the menu

0

I made an ASP.NET MVC application that receives some data via API, handles and displays on the screen. The data is correctly received, and I can display them normally, except for one place: The menu for mobile devices within _layout.cshtml . I'll explain:

I get the data via API:

    public async Task<ActionResult> Index(string id)
    {
        List<establishment_employee> employee = new List<establishment_employee>();
        establishment_employee emp = new establishment_employee();

        HttpClient http = new HttpClient();
        employee = await http.Get<List<establishment_employee>>("establishmentemployee/" + id);

        emp = employee.FirstOrDefault();

        ViewBag.Title = "Dashboard";
        ViewData["employee"] = emp;

        return View(employee);
    }

Access the ViewData within _layout.cshtml:

@{
    Admin.Models.establishment_employee employee = new Admin.Models.establishment_employee();
    employee = (Admin.Models.establishment_employee)ViewData["employee"];
}

I I CAN display information on title of the page:

<head>
    <title>@ViewBag.Title - @employee.establishment.FANTASY_NAME.ToString() </title>
    .
    .
    .
</head>

But when I try the SAME command on the menu:

    <div class="layout-w">
        <!-------------------- START - Mobile Menu -------------------->
        <div class="menu-mobile menu-activated-on-click color-scheme-dark">
            <div class="mm-logo-buttons-w">
                <a class="mm-logo" href="@Url.Action("Index", "Home")"><img src="img/logo.png" /><span> @employee.establishment.FANTASY_NAME.ToString() </span></a>
                <div class="mm-buttons">
                    <div class="content-panel-open">
                    .
                    .
                    .                        
                    </div>
                </div>
            </div>
        </div>
    </div>

The following error occurs:

If I remove these two Razor code snippets from the page, it finishes compiling, correctly adding the rest of the Razors across the page.

I debugged the application, saw that the object is filled, but the error continues.

I need a light of what this problem can be.

Thank you!

    
asked by anonymous 09.03.2018 / 20:57

0 answers