My issue is when I create this controller :
[HttpPost("[Action]")]
public IActionResult CreateFile(string word){
word = "test";
byte[] b = Encoding.ASCII.GetBytes(word);
var txtBuilder = new StringBuilder();
txtBuilder.Append(b);
var txtContent = txtBuilder.ToString();
var txtStream = new MemoryStream(Encoding.UTF8.GetBytes(txtContent));
return File(txtStream,"text/plain","license.dat");
}
When I try this request on swagger, it allow me to download a file. When I download the file the content is :
System.Byte[]
But when I test this on swagger :
[HttpPost("[Action]")]
public IActionResult CreateFile(string word){
word = "test";
byte[] b = Encoding.ASCII.GetBytes(word);
return BadRequest(b);
}
the result of b is :
dGVzdA==
I don't want to see test or System.Byte[] inside the created file I want to see the result of b on the created file.
MemoryStream? 4 bytes, one for each character? Or some textual representation (e.g. in hex)?wordis"test". What you've claimed to be the result is the base64-encoded version of the ASCII-encoded bytes of "test". Where are you seeing that result? Please edit your question to make it a lot clearer - while it's unclear, we're not going to be able to help you.