StructureMap MVC 5 html.Action Issue

2019-02-17 18:29发布

I am trying to call an Action from my view using @Html.Action("ActionName","controllerName"). But my page fails to load with below error:

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.

1条回答
神经病院院长
2楼-- · 2019-02-17 18:45

You need to add

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

in IoC.cs file. This should be done for every controller in your project.

For more details check this link.

查看更多
登录 后发表回答