Hey, on a page, I loop through a collection of objects that contain fields related to a photo album, to create a page of different albums. I envision linking to a specific photo album page by passing the model from the link to the controller - e.g.;
The URL.Action isn't working, the model that is being passed to that controller is null. How do I go about passing along a specific instance of the object w/ its contents back to the controller?
Thanks! I suspected that was the case but was surprised to find examples of objects being passed from the view/controller in a Google search - clearly I didn't understand the use case there.
i think Nigel ist right. You can't pass objects in a GET - Request. But you could use newtonsoft.json to convert the object into a json-string and convert it back to your model-type again in your controller.
Not able to pass model from view to controller
Hey, on a page, I loop through a collection of objects that contain fields related to a photo album, to create a page of different albums. I envision linking to a specific photo album page by passing the model from the link to the controller - e.g.;
The URL.Action isn't working, the model that is being passed to that controller is null. How do I go about passing along a specific instance of the object w/ its contents back to the controller?
Hi Nancy
I might be wrong but you can only pass a simple value in the action, not an object.
So potentially the following
Hope this helps
Nigel
Thanks! I suspected that was the case but was surprised to find examples of objects being passed from the view/controller in a Google search - clearly I didn't understand the use case there.
Hi Nancy,
i think Nigel ist right. You can't pass objects in a GET - Request. But you could use newtonsoft.json to convert the object into a json-string and convert it back to your model-type again in your controller.
See this example: https://www.newtonsoft.com/json/help/html/SerializingJSON.htm
~Jonathan
Perfect! I'll try using this and see what comes out of it. Thank you!
is working on a reply...