MVC How to pass viewmodel as contructor parameter to controller

Need code snippet that is passed a viewmodel to a controller action

So say I have a view called INDEX that inhertis from IndexPageViewModel

and in my controller I have methods
Index   get
Index   post   which should take  IndexPageViewModel as a constructor parameter

I need this because I am trying to maintain the selected value of a html.dropdown selected item during postback in an MVC view
Who is Participating?
HohlovDimaConnect With a Mentor Commented:
Can you give more details b/c as i understand you have model and you need to pass it to controller method. As i know mvc makes it automatically. You just need to write in contructor parameters of method
SomeMethod(IndexPageViewModel model)

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.