How to return a File in a different method than the main one?
when you inline an entire method block (not just a single expression), you must return
what you want to be the output of the block. In your case you are not capturing the result of SendJsonFile
to return it:
app.MapGet("/download", () =>
{
string data = "json data";
var result = SendJsonFile(data);
return result;
});