A GET action reads a parameter from the request body, which GET requests do not reliably carry

tx0/csharp:body-on-get-actionrecommendedwarningreliability/logicdepth fastbug

What it finds

HTTP gives a body no meaning on GET; proxies and clients may drop it, and browsers cannot send one. A [FromBody] parameter on a [HttpGet] action therefore arrives empty for many callers. Query parameters, or a POST, carry the data.

From the rule's source, body_on_get_action.rs.

Example from the rule's tests
using Microsoft.AspNetCore.Mvc; class SearchController : ControllerBase{    [HttpGet]    public IActionResult Find([FromBody] string query) => Ok();tx0 reports: the GET action reads query from the body     [HttpPost]    public IActionResult Save([FromBody] string item) => Ok();}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:body-on-get-action" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/csharp:body-on-get-action] reason="..."

tx0 explain tx0/csharp:body-on-get-action shows the same in the terminal. Found a false positive? Report it.