依赖注入 – StructureMap MVC 5 html.Action Issue

前端之家收集整理的这篇文章主要介绍了依赖注入 – StructureMap MVC 5 html.Action Issue前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图使用@ Html.Action(“ActionName”,“controllerName”)从我的视图中调用一个Action.但我的页面无法加载以下错误

A single instance of controller ‘Ki_PathwaysWeb.Areas.LearningManager.Controllers.ActionController’
cannot be used to handle multiple requests. If a custom controller
factory is in use,make sure that it creates a new instance of the
controller for each request.

我正在使用结构图进行依赖注入.请帮帮我,我错过了什么.

解决方法

你需要添加

x.For< {Your controller name}>().AlwaysUnique();

在IoC.cs文件中.应该为项目中的每个控制器执行此操作.

有关详细信息,请查看this link.

猜你在找的设计模式相关文章