我正在尝试使用 @Html.Action("ActionName","controllerName")
从我的 View 中调用操作.但是我的页面无法加载并出现以下错误:
A single instance of controller 'Web.Areas.Area1.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.
我正在使用结构图进行依赖注入(inject)。请帮助我我错过了什么。
最佳答案
您需要添加x.For<{Your controller name}>().AlwaysUnique();
在 IoC.cs 文件中。这应该为项目中的每个 Controller 完成。
更多详情请查看this link .
关于dependency-injection - StructureMap MVC 5 html.Action 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24743215/