System.MissingMethodException: No parameterless constructor defined for this object

前端 未结 2 1517
攒了一身酷
攒了一身酷 2021-01-25 22:52

I\'m using MVC 2.0 with a Html.ListBoxFor as below:

<% using (Html.BeginForm()) { %>

       \" />

        <%=         


        
相关标签:
2条回答
  • 2021-01-25 23:37

    Does your LogOnModel have a parameterless constructor? It needs one for the DefaultModelBinder to instantiate it. Additionally, when you post the exception, please post the full stack trace from the exception object, else we're simply guessing where the error actually took place.

    0 讨论(0)
  • 2021-01-25 23:45

    This error is coming from the ControllerFactory not the View. It is stating that you don't have a paramerless constructor in your Controller. The DefaultControllerFactory for ASP.NET MVC can only instantiate a Controller with a public parameter less constructor. If you plugin your own ControllerFactory and use some DI/IoC tool you can bypass this limitation.

    0 讨论(0)
提交回复
热议问题