【问题标题】:ASP.NET Response - UTF-16 encoded file but nothing shown in the browserASP.NET 响应 - UTF-16 编码文件,但浏览器中未显示任何内容
【发布时间】:2017-06-19 18:30:03
【问题描述】:
我正在尝试从 ASP.NET 应用程序发送 UTF-16BE 文本文件作为 HTTP 响应。
Response.ContentType = "text/plain";
Response.ContentEncoding = System.Text.UnicodeEncoding.BigEndianUnicode;
Response.WriteFile(filename);
但结果没有显示,Fiddler 也没有显示任何编码
是我还是网络浏览器不喜欢 utf-16 文本?
【问题讨论】:
标签:
c#
asp.net
encoding
utf-8
utf-16
【解决方案1】:
不,您的网络浏览器不是问题。
这段代码:
context.Response.ContentType = "text/html";
context.Response.ContentEncoding = UnicodeEncoding.BigEndianUnicode;
context.Response.Write("Hello World");
产生预期的内容编码:
但是一旦您使用context.Response.WriteFile,内容编码就会被删除。不确定这是否是一个功能。我假设另一端的软件必须根据返回的输出确定内容编码。