MVC ViewModel Error - No parameterless constructor defined for this object

后端 未结 3 969
一个人的身影
一个人的身影 2020-12-09 12:52

I would like to know how can I use my ViewModel on the Create Action? I tried several examples I found here in the forum, but none solved my problem. I\'ve been racking my b

3条回答
  •  [愿得一人]
    2020-12-09 13:02

    For me the problem was in the BeginForm() method itself. It looked like this:

    @using (Html.BeginForm("MyAccount", "MyController", Model))
    

    Copied and pasted in from another project's Login page, which doesn't have a dropdown.

    Anyway, remove the Model from the parameter list and it all works just fine :)

提交回复
热议问题