加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 04:56:57 所属栏目:百科 来源:网络整理
导读:我试图使用@ Html.Action(“ActionName”,“controllerName”)从我的视图中调用一个Action.但我的页面无法加载以下错误: A single instance of controller ‘Ki_PathwaysWeb.Areas.LearningManager.Controllers.ActionController’ cannot be used to handl
我试图使用@ 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读