StructureMap MVC 5 html.Action 问题 [英] StructureMap MVC 5 html.Action Issue

查看:29
本文介绍了StructureMap MVC 5 html.Action 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 @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:

控制器'Web.Areas.Area1.Controllers.ActionController'的单个实例不能用于处理多个请求.如果自定义控制器工厂正在使用中,确保它创建了一个新的实例每个请求的控制器.

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.

推荐答案

需要添加

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆