0

I have a razorview which uses a layout with name ReportsLayout. I was pulling configuration strings by injecting IConfiguration into the Layout as well as page views as below.

_Layout View @using Microsoft.Extensions.Configuration @inject IConfiguration Configuration

Page View @using Microsoft.Extensions.Configuration @inject IConfiguration Configuration @model DayFuelSalesView @{ Layout = "~/Views/Shared/_ReportsLayout.cshtml"; }

It was working fine until I added some more code to the razorview page which is basically pure html code.

After adding the code, during the debugging, the debugger show error as below in the web browser while trying to open the page. Error Details

This is the first time I am seeing such kind of error and I am unable to get it to work. Any help is appreciated.

1 Answer 1

1

Try to check if you have @Render xxx{} in your Page View.If so,you need to add @await RenderSectionAsync("xxx", required: false) to your _Layout View.Try to refer to the Sections in the official doc.For example,if you have the following code in your view:

@section Scripts
{
    ...
}

You need to make sure you have @await RenderSectionAsync("Scripts", required: false) in your _ReportsLayout.cshtml.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer. the error was caused by the intellicode which replaced the '@section Styles' To '@section Configuration' in the RazorView. Since, it was a large file it took a while to identify it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.