That's how I try to get a view that includes a class with. The way I get it on it is by writing:
@Html.Partial("View/ViewBar_Info/Menu")
If I'm doing an ordinary MVC view, I can do that. but that's because I have to get the menu that is being controlled via the database. Therefore, I try to do this here.
How can I call that view?
Error Text:
An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.
Generated Code One or more compilation references are missing. Ensure
that your project is referencing 'Microsoft.NET.Sdk.Web' and the
'PreserveCompilationContext' property is not set to false.
Update EIDT:
I make this from _Layout.cshtml
@Html.Partial("View/ViewBar_Info/Menu.cshtml")
in the Menu.cshtml:
@page
@model NewWebsite_SITE_2018.Pages.View.ViewBar_Info.MenuModel
@foreach (var item in Model.GetListMenu)
{
<a>@item.Name</a>
}
Error now its:
InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'NewWebsite_SITE_2018.Pages.IndexModel', but this ViewDataDictionary instance requires a model item of type 'NewWebsite_SITE_2018.Pages.View.ViewBar_Info.MenuModel'.
What I'm trying to do is in my layout, so I'll call my menu so come on the single page.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…