10 Replies
i just have a model >
that's called on the main controller >
but when i call it on the view, it returns me that's null
Could you share the Home .cshtml code?
this is the code from _Layout.cshtml, right? You inject model in the controller page, which is located in the Views/Home/Index.cshtml
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.exactly
how can i do it ?
all you need is to call the model in Views/Home/Index.cshtml instead of _Layout.cshtml and this will work.
You can read about layout here: https://learn.microsoft.com/en-us/aspnet/core/mvc/views/layout?view=aspnetcore-7.0
Layout in ASP.NET Core
Learn how to use common layouts, share directives, and run common code before rendering views in an ASP.NET Core app.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.