Since I haven't found a concrete solution to having the section rendered, I copied the code of my HomeTab section from my view and inserted it directly to content section of my Kendo Tabstrip.
InvalidOperationException: The following sections have been defined but have not been rendered by the page at '/Views/Shared/UserLayout.cshtml'
I'm trying to convert an ASP.NET MVC project to ASP.NET Core MVC. I have done most of the work but got stuck in a weird issue.
My project has a view User.cshtml
and a layout page UserLayout.cshtml
, based on an API call I was returning the view and its master page through return View("User", "UserLayout");
in ASP.NET MVC.
The method expects a view name and a master name. This overload doesn't exists anymore in ASP.NET Core MVC so I have set the layout on top of my User.cshtml
page like this:
@{ Layout="~/Views/Shared/UserLayout.cshtml"; }
and returned just the view name from my controller.
Now my layout page contains Kendo tabstrip and in its content I'm rendering sections like @RenderSection("HomeTab", true)
which are defined in UserLayout.cshmtl
@section HomeTab {}
. This is working completely fine with the ASP.NET MVC project, but when I run the ASP.NET Core MVC project, I'm getting this exception:
InvalidOperationException: the following sections have been defined but have not been rendered by the page at '/Views/Shared/UserLayout.cshtml': 'HomeTab'. To ignore an unrendered section call IgnoreSection("sectionName").
I have tried removing the section, changing the required attribute to false but the error remains. It seems I didn't need to convert views from .NET to .NET Core but it's this small thing that has got me stuck.