How to GetBytes() in C# with UTF8 encoding with BOM?

前端 未结 4 1001
余生分开走
余生分开走 2020-11-27 16:06

I\'m having a problem with UTF8 encoding in my asp.net mvc 2 application in C#. I\'m trying let user download a simple text file from a string. I am trying to get bytes arra

4条回答
  •  余生分开走
    2020-11-27 16:25

    Remember that .NET strings are all unicode while there stay in memory, so if you can see your csvString correctly with the debugger the problem is writing the file.

    In my opinion you should return a FileResult with the same encoding that the files. Try setting the returning File encoding,

提交回复
热议问题