2

I am trying to call an action for a partial view in my _Layout view. If I place the action in the home controller, it works, but if I create a new controller StatusController, place the same child action method in it and call it from the _Layout view I get an error:

The Contoller path '/' was not found or does not implement IController.

from layout view _Layout.cshtml I call the action like so:

 @{Html.RenderAction("_GetforStatus", "StatusController");}

_GetforStatus() is the child action method inside the StatusController, as well as the name of the partial view.

How can i get ASP.NET MVC 4 to find my new controller?

haim770
  • 48,394
  • 7
  • 105
  • 133
antman1p
  • 514
  • 2
  • 11
  • 25

2 Answers2

2

You have to pass controller name without Controller postfix to make it work.The framework itself will exectue that Controller's action

Write like this:

@{Html.RenderAction{"_GetforStatus", "Status");}

or you can also use this:

@Html.Action("_GetforStatus","Status")
Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160
2

The post-pended Controller moniker is implied. Also, check your parentheses. Try below to render the partial in the Layout.

 @{Html.RenderPartial("_GetforStatus", "Status");}
Dillon
  • 687
  • 6
  • 9