RenderAction 在当前区域的当前控制器中找不到操作方法

发布于 2024-08-25 13:43:55 字数 512 浏览 5 评论 0原文

我正在创建一个使用区域的 ASP.NET MVC 2 (RTM) 项目。一个区域的Home控制器的Index动作需要使用RenderAction来生成页面的一个子区域。调用的操作也在同一个 Home 控制器中定义。所以调用应该是:

<% Html.RenderAction("List") %>

但是,我得到一个例外:

在控制器“RareBridge.Web.Areas.Events.Controllers.HomeController”上找不到公共操作方法“List”。

请注意,我不在“活动”区域!我在一个完全不同的区域。如果我删除“事件”主控制器,则异常仍然会发生,但会命名另一个控制器(仍然不是我希望它调用的控制器)。

我还尝试向 RenderAction 方法提供控制器名称和区域,但出现了相同的异常。这是怎么回事?

顺便说一句:我使用 Autofac 作为我的 IoC 容器

I'm creating an ASP.NET MVC 2 (RTM) project that uses areas. The Index action of the Home controller of one area needs to use RenderAction to generate a sub-section of the page. The action called is also defined in the same Home controller. So the call should just be:

<% Html.RenderAction("List") %>

However, I get an exception:

A public action method 'List' was not found on controller 'RareBridge.Web.Areas.Events.Controllers.HomeController'.

Note that I'm not in the "Events" area! I'm in a completely different area. If I remove the "Events" home controller, then the exception still occurs but names a different controller (still not the one I want it to call).

I've also tried providing the controller name and area to the RenderAction method, but the same exception occurs. What is going on here?

BTW: I am using Autofac as my IoC container

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

铁轨上的流浪者 2024-09-01 13:43:55

您调用的操作可能具有与当前请求不匹配的过滤器属性(即 AcceptVerbs)。从“列表”操作中删除过滤器,然后重试。

Probably action you call has filter attribute (i.e. AcceptVerbs) which doesn't match current request. Remove filters from "List" action and try again.

通知家属抬走 2024-09-01 13:43:55

使用以routeValues作为参数的renderaction重载,并使用area属性重定向到特定区域:

fi

<% Html.RenderAction("Edit", module.Value, new { area = "Modules", id = module.Key }); %>

Use the renderaction overload which takes routeValues as parameter and use the area property to redirect to a specific area:

f.i.

<% Html.RenderAction("Edit", module.Value, new { area = "Modules", id = module.Key }); %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文