1

I have Two Layouts, MainLayout and SubLayout. SubLayout inherits from MainLayout. In MainLayout`I have Section Like this :

<ul>
  @RenderSection("LostSection",true)              
</ul>

And in SubLayout have :

<div id="main-content">
@RenderBody()
</div>

@section LostSection{
    @{Html.RenderAction(MVC.Home.ActionNames.NewFind, MVC.Home.Name)}
}

and my Action is :

 [ChildActionOnly]
    public virtual ActionResult NewFind()
    {
        var things = _things.NewThings(ThingType.Found).Select(x => new LastThingViewModel {HasReward=x.IsReward,Id=x.Id,Reward=x.Reward,Title=x.Title});

        return PartialView(MVC.Partials.Views._NewFound,things);

    }

But when I run the project I get this error:

Section not defined: "LostSection"

And my other views inherits SubLayout.

Thanks for help.

osman Rahimi
  • 1,427
  • 1
  • 11
  • 26

1 Answers1

1

Add below line to SubLayout:

@section Header {@RenderSection("LostSection", true)}

More info: In MVC Razor, how do you do a RenderSection defined below a sub-layout?

Community
  • 1
  • 1
Mohsen Esmailpour
  • 11,224
  • 3
  • 45
  • 66