How to configure StructureMap for asp.net MVC 5

前端 未结 4 2128
Happy的楠姐
Happy的楠姐 2021-02-02 14:29

I\'m getting below error. I setup it similar to asp.net mvc 4.

No parameterless constructor defined for this object. Description: An unhandled exception

4条回答
  •  灰色年华
    2021-02-02 14:54

    I have a detailed walk-through showing how to get this working using the latest StructureMap for MVC 5 package here: http://ardalis.com/resolving-dependencies-in-asp.net-mvc-5-with-structuremap

    It's not all that different from what was necessary in ASP.NET MVC 3, which I previously published: http://ardalis.com/How-Do-I-Use-StructureMap-with-ASP.NET-MVC-3

    Basically you just install the correct NuGet package, modify your controllers to accept dependencies, and wire up your interfaces to your implementations in IoC.cs. If you follow StructureMap's default convention, you can get this wireup to occur automatically for many types.

提交回复
热议问题