asp.net mvc - The following sections have been defined but have not been rendered for the layout page even though I have set required:false -


this question has been asked lot , answer has been set @rendersection("mysection", false)

however in case not working.

the error is:

the following sections have been defined have not been rendered layout page "~/views/shared/kittenlayout.cshtml": "styles".

my pages are:

  • kitten.cshtml has layout = "~/views/shared/kittenlayout.cshtml";
  • kittenlayout.cshtml has 2 sections defined, @section stuff , section @otherstuff, , has layout = "~/views/shared/_kittenmasterlayout.cshtml";
  • _kittenmasterlayout.cshtml has @rendersection("styles", required: false)

why getting error?

i have fixed this, apparently there no inheritance, if have pages a->b->c main page, b master page, , c master-master-page, if define section on c , render on you'll error. have add b , pass through.

adding page b fixed it:

@section styles {     @rendersection("styles", required: false) } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -