Outputting \n as a line break when returning string as a file
This is hopefully very simple one and I think it lies in the encoding.
I have a string which contains \n for new lines
public ActionResult DownloadText(int id)
{
var text =
"BB2B-XX2A-F2CR-2MMQ-K79A\n3AP2-PH3H-M2QE-2DRH-D73A\nGPD3-AU3Q-P2DN-2FEX-P86A";
return File(new
System.Text.ASCIIEncoding().GetBytes(tempKeys.ToString()),
"text/plain", "Key"+ id.ToString() + ".txt");
}
I would like to display each item on a different line when output in the
text file. BB2B-XX2A-F2CR-2MMQ-K79A 3AP2-PH3H-M2QE-2DRH-D73A
GPD3-AU3Q-P2DN-2FEX-P86A
No comments:
Post a Comment