Is there an easy way to pass an object from my view to controller?
I tried ViewData["newPerson"] but that didn’t work.
Session["newPerson"] works but are there other ways that are more recommended?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Are you implementing a form? Your best bet would be to create a new action on your controller that takes in your object. Your controller would have a method like this:
Or if you want it to respond to posts:
Then your view would call your controller action via a link or a form submit. One example for a link: