【发布时间】:2015-03-09 08:41:19
【问题描述】:
我正在使用 dropzone.js 将文件上传到 Web API 2 服务。读取多部分流会产生乱码的俄语字符。例如,当我上传名称为 Русское название - 俄语字符的文件时,它会给出 ????? ??? - 俄语字符。
我确信 dropzone.js 工作正常,这只是一个 Web API 问题。
这里是 GetStream 方法。
public override Stream GetStream(HttpContent parent, HttpContentHeaders headers)
{
// For form data, Content-Disposition header is a requirement
ContentDispositionHeaderValue contentDisposition = headers.ContentDisposition;
if (contentDisposition != null)
{
// We will post process this as form data
_isFormData.Add(String.IsNullOrEmpty(contentDisposition.FileName));
return new MemoryStream();
}
// If no Content-Disposition header was present.
throw new InvalidOperationException(
string.Format("Did not find required '{0}' header field in MIME multipart body part..",
"Content-Disposition"));
}
【问题讨论】:
-
这与经典 ASP 无关。 ASP.NET 和 Classic ASP 是两种不同的技术。
标签: asp.net asp.net-web-api asp.net-web-api2 multipart