this is my _Layout.cshtml page :
@RenderBody()
This is my _PartialMenu.cshtml Page
@using DyMenu.Pages
@model DyMenu.Pages.IndexModel
This is my Index.cshtml.cs page .
public class IndexModel : PageModel
{
#region Declartion
private IMenuItemAccess _menuItemAccessDA;
private readonly IConfiguration _configuration;
#endregion
public IndexModel(IConfiguration configuration)
{
_configuration = configuration;
}
[BindProperty]
public IEnumerable
database : Menu
1, 0, 'Index', 'Index'
2, 0, 'Privacy', 'Privacy'
3, 0, 'Service', 'Service'
4, 0, 'Products', 'Products'
5, 0, 'Register', 'Register'
Other than index page not working . the following error thrown we i run . can anyone suggest with solution
Here Menu item is generated from index.cshtml.somewhere in this part made mistake. i am not sure how to pass the
menuitem model commonly
Error :
InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'DyMenu.Pages.ProductsModel',
but this ViewDataDictionary instance requires a model item of type 'DyMenu.Pages.IndexModel'.
Thanks in advance
Karthik.K

Posted Aug 1, 2025, 10:10 PM
Did you find the answer you were looking for? This is the line that needs to be changed: public class IndexModel : PageModel