StructureMap MVC 5 html.Action Issue

旧街凉风 提交于 2019-12-01 03:56:52

问题


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 '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.

I am using structure map for Dependency injection. Please help me what am i missing.


回答1:


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.



来源:https://stackoverflow.com/questions/24743215/structuremap-mvc-5-html-action-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!