I am making a dynamic CVS report file in my controller in the format of StringBuilder. I have tried this code to return the file:
public async Task GetCvsAsync(....) { .... //making the file
        using (MemoryStream stream = new MemoryStream())
        {
            StreamWriter objstreamwriter = new StreamWriter(stream);
            objstreamwriter.Write(res.ToString());
            objstreamwriter.Flush();
            objstreamwriter.Close();
            return File(stream.ToArray(), "application/octet-stream", "test.csv");
        }
    } 
it makes the correct result but in the console response header (nothing happens in the front) like this:

if I right-click on the console and click open in a new tab, it will start to download the file. I have tried this way as well:
var f = File(Encoding.UTF8.GetBytes(res.ToString()), "text/csv", "authors.csv");
return f;
res is in the type of StringBuilder.
I want to download automatically begins after the file is ready, I have no idea what should I do.
note: this action called by a href tag onClick event on my razor page:
function cvs(meID, oID, tID) {
        $.get("/Dashboard/GetCVS?meID=" + meID
            + "&oID=" + oID+ "&tID=" + tID);
    }
