How to resolve Error CS0103: The name 'RenderBody' does not exist in the current context

If you are developing Razor Pages for Asp.Net core application, you may run into following compile time error.

Error CS0103 The name 'RenderBody' does not exist in the current context

RenderBody directive can only be used from a layout page. This directive is used to render page content. Layout is not a page. It is container of the page.

Above error will be raised when you will include @RenderBody directive on a page with @page directive at the top. By adding @page you have directed Asp.Net core that it is a page and not layout. Therefor compiler does not expect RenderBody to be included on the page.

To fix this error, remove @page directive from layout.

Search

Social

Weather

25.7 °C / 78.3 °F

weather conditions Mist

Monthly Posts

Blog Tags