Creating a text file on the fly and have it download/save on client side
问题 In our ASP.NET Core 1.1, EF Core 1.1 app we have populated a string with some data from SQL Server and would like to have a text file created out of it on the fly and have a user save/download from the client side. In old days we used to do it as follows: List<string> stringList = GetListOfStrings(); MemoryStream ms = new MemoryStream(); TextWriter tw = new StreamWriter(ms); foreach (string s in stringList) { tw.WriteLine(s); } tw.Flush(); byte[] bytes = ms.ToArray(); ms.Close(); Response