@await RenderSectionAsync giving "Cannot await method group" error

Akhil Josef 20 Reputation points

I am creating a razor application consisting of two simple user inputs and two navigation tabs with 'save' and 'cancel' button for the user inputs. I have pasted below part of the _Layout.cshtml code giving the titled error. Am I missing something ?

````    <div class="container">`

`        <main role="main" class="pb-3">`

`            @RenderBody ( )`

`        </main>`

`    </div>`

`    <footer class="border-top footer text-muted">`

`        <div class="container">`

`            &copy; 2023 - Landing Page`

`        </div>`

`    </footer>`

`    <script src="~/lib/jquery/dist/jquery.min.js"></script>`

`    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>`

`    <script src="~/js/site.js" asp-append-version="true"></script>`

`    `**`@await RenderSectionAsync`**` ("Scripts", required:false)`


Microsoft Technologies based on the .NET software framework.
3,518 questions
A set of technologies in the .NET Framework for building web applications and XML web services.
4,281 questions
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,449 questions
{count} votes

Accepted answer
  1. Tiny Wang-MSFT 2,006 Reputation points Microsoft Vendor

    Hi @Akhil Josef , I can reproduce your issue in my side with your codes, could you please remove the "space" in your @await RenderSectionAsync("Scripts", required:false) ? The same for @RenderBody(), you should remove the space.User's image


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    Best regards,

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Akhil Josef 20 Reputation points

    hi @Tiny Wang-MSFT , thanks a lot for the point out. It worked and I think I must be more careful on formatting the code files to avoid this in future.