@await RenderSectionAsync giving "Cannot await method group" error

Akhil Josef 20 Reputation points
2024-05-21T04:33:58.8933333+00:00

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 ?

 </header>
````    <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)`

`</body>`

`</html>`
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,928 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,623 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,595 questions
{count} votes

Accepted answer
  1. Tiny Wang-MSFT 2,731 Reputation points Microsoft Vendor
    2024-05-21T05:50:06.35+00:00

    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,
    Tiny

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Akhil Josef 20 Reputation points
    2024-05-21T09:37:06.28+00:00

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.