When I try to use Html.Action
in ASP.NET MVC 3 for a controller in a different namespace from the current controller I get an error :
Code:
@Html.Action("Foo", "Application", new { id = "FG2" })
Error :
The controller for path '/rrmvc/store/checkout' was not found or does not implement IController.
This error only occurs when the controller ApplicationController
is in a different NAMESPACE from the current controller such as StoreControllers.CheckoutController
(in fact they're in completely different areas too).
Is there no way to specify a namespace when calling Html.Action
(none of the obvious ways like fully qualifying the namespace seem to work)?
There are no lambda methods to use, and I had no luck using Html.RenderAction
in MVC3 RTM.
Edit : I think it might be related to the area - or perhaps this could be a complete red herring too. I have another controller in a different namespace that DOES work correctly - so I think the problem is more complicated. I'll reply with an answer if i figure it out - or just delete this question if not to avoid confusion!
If the controller is in a different area you may try specifying this area name:
@Html.Action("Foo", "Application", new { id = "FG2", area = "foo" })
and if you are already inside the area and you want to render an action located on a controller in the root you could try this:
@Html.Action("Foo", "Application", new { id = "FG2", area = "" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With