Optional sections appear to be required

112 views Asked by At

I have a Layout page which has the following

@RenderSection("Style", required: false)
@RenderSection("Scripts", required: false)
@RenderBody()

My project was working just fine until a few days ago, now all the new views I create I get the following error

The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Style; Scripts".

I Get the same error for RenderBody if I remove Style and Script. As I said, my old pages work just fine, the new pages I create have this error, I even replaced the whole code of an old page in a new page and still got the same error.

1

There are 1 answers

0
Mr.K On

Figured it out,

I have a code at the top of the page in @{} which checked for permission, somehow that was causing this issue.

It's working find now, until next time :D