DasRakel
DasRakel

Reputation: 73

RenderAction a list of a model in the layout

So I want to put a list of newsitems in _Layout.cshtml
I have a News model and a Show Action in its controller, and I want to put it in there with a RenderAction.

@Html.RenderAction("Show","News");

Does not seem to work. But http://localhost:49295/News/Show/ does work I should be using renderaction right?

EDIT

@{Html.RenderAction("Show","News");}

stackoverflowerror, probably because I just put an action that uses the layout, in the layout itself? How do I not use the default layout for this view?

Upvotes: 1

Views: 1981

Answers (2)

Tz_
Tz_

Reputation: 2949

Set the layout to null in the View

@{ Layout = null; }

Upvotes: 4

Chris
Chris

Reputation: 3201

In your View try:

@{Html.RenderAction("Show","News");}

Upvotes: 0

Related Questions