title | description | author | monikerRange | ms.author | ms.date | uid |
---|---|---|---|---|---|---|
MVC1006: Methods containing TagHelpers must be async and return Task |
Learn about analysis rule MVC1006: Methods containing TagHelpers must be async and return Task |
pranavkm |
>= aspnetcore-3.1 |
wpickett |
10/22/2021 |
diagnostics/mvc1006 |
Value | |
---|---|
Rule ID | MVC1006 |
Fix is breaking or non-breaking | Breaking |
A tag helper was defined inside a Razor function that executes synchronously
Tag Helper execution is asynchronous. When used inside a method or a lambda within a Razor Page, the containing function must also be declared to be async.
Consider the following cshtml file:
void Helper(string controller)
{
<a asp-controller="@controller">Home</a>
}
asp-controller
is a tag helper and will trigger this rule.
Declare the function to be async and Task returning:
async Task Helper(string controller)
{
<a asp-controller="@controller">Home</a>
}
Do not suppress a warning from this rule.