Reputation: 878
Using ASP.NET MVC 2 and and Html.RenderAction in my masterpage implemented as below throws an error with "the controller for path '/' was not found":
I'm a bit of a newbie, do i have to do something in RegisterRoutes to make this work?
<% Html.RenderAction("TeaserList", "SportEventController"); %>
public class SportEventController : Controller
{
public string TeaserList()
{
return "hi from teaserlist";
}
}
Upvotes: 0
Views: 4234
Reputation: 96606
I'm not sure but I guess the following things are wrong:
RenderAction("TeaserList", "SportEvent")
without the Controller suffixUpvotes: 7
Reputation: 1835
In order for that to work, TeaserList()
has to be a method that returns an ActionResult
like:
`
public virtual ActionResult TeaserList()
{
return View();
}
`
If you want "Hi from teaserlist" then you could have that in a View called TeaserList or you could add
`ViewData["teaserList"] = "hi from teaserlist";`
and have it rendered in your view.
Upvotes: 0