❔ How can I pass model data to my controller if I have another POCO class in the model?
Let's imagine that I have the classes:
How can I create a simple editor for these classes? I mean that my
Create()
method takes something like this:
Of course I cannot bind Entrances
property because it is another class and it is an array. How can I do the trick? What should my controller accept and how can I do it in the view?9 Replies
Is this Blazor or something special? Because in a normal web api, you just do this without any bind attribute at all
and it works exactly as expected, assuming you are taking json in
No, it's ASP.NET Core 7
ok then its literally just
I've done this using the official tutorial https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/controller-methods-views?view=aspnetcore-7.0
Part 6, controller methods and views in ASP.NET Core
Part 6, add a model to an ASP.NET Core MVC app
ah, this wont be as simple as this isnt for a json webapi - this is for html forms
Thank you. You've also mentioned a json WebAPI, is it the right tutorial to do it? https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-7.0&tabs=visual-studio
Tutorial: Create a web API with ASP.NET Core
Learn how to build a web API with ASP.NET Core.
sure, that seems okay
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.