该代码应该导致文件下载...
public HttpResponseMessage Export()
{
var byteArray = Encoding.UTF8.GetBytes("Hello World!");
var stream = new MemoryStream(byteArray);
var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StreamContent(stream),
};
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = "myFile.csv"
};
result.Content.Headers.ContentType = new MediaTypeHeaderValue("text/csv");
return result;
}
相反,我收到此消息...
{“版本”:{“主要”:1,“次要”:1,“构建”:-1,“修订”:-1,“主要修订”:-1,“次要修订”:-1}, “ content”:{“ headers”:[]},“ statusCode”:200,“ reasonPhrase”:“ OK”,“ headers”:[],“ requestMessage”:null,“ isSuccessStatusCode”:true}
我在做什么错了?
答案 0 :(得分:1)
r