RenderAction not finding action method in current controller in current area
Asked Answered
O

2

6

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

Obidiah answered 15/3, 2010 at 14:59 Comment(0)
H
15

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

Hedveh answered 20/7, 2010 at 16:18 Comment(0)
D
4

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 }); %>
Desiderata answered 12/4, 2010 at 6:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.