StructureMap MVC 5 html.Action问题 [英] StructureMap MVC 5 html.Action Issue
问题描述
我想打电话给使用 @ Html.Action(ActionName,controllerName)
从我的观点的行动。不过,我的网页失败,下面的错误加载:
I am trying to call an Action from my view using @Html.Action("ActionName","controllerName")
. But my page fails to load with below error:
控制器的单个实例Ki_PathwaysWeb.Areas.LearningManager.Controllers.ActionController
不能用来处理多个请求。如果自定义控制器
工厂正在使用,确保它产生的一个新实例
控制器为每个请求。
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.
我使用依赖注入的构造图。请帮我我在想什么。
I am using structure map for Dependency injection. Please help me what am i missing.
推荐答案
您需要添加
x.For< {你的控制器名称}方式>()AlwaysUnique();
在IoC.cs文件。这应该在项目中的每个控制器来完成。
in IoC.cs file. This should be done for every controller in your project.
有关详细信息,请检查此链接。
For more details check this link.
这篇关于StructureMap MVC 5 html.Action问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!