在我的WCF服务中,我需要在响应中将MIME Multipart数据(文本文件)返回给客户端。虽然响应返回给客户端,但我没有看到返回的数据。事实上,我没有看到我在服务器端设置的任何内容被返回给客户端。有人可以对此有所了解吗?以下是我在构建和返回响应的代码中所拥有的内容:
MultipartFormDataContent formData = new MultipartFormDataContent("myboundary");
HttpResponseMessage responseMsg = new HttpResponseMessage();
try
{
using (Stream fs = File.OpenRead("C;\\mydata.txt"))
{
formData.Add(new StreamContent(fs), "Payload", "mydata.txt");
}
}
catch (Exception ex)
{
ServiceUtil.LogMessage(ex.Message);
}
responseMsg.StatusCode = System.Net.HttpStatusCode.OK;
responseMsg.Content = formData;
WebOperationContext.Current.OutgoingResponse.ContentLength = 2048;
WebOperationContext.Current.OutgoingResponse.ContentType = "multipart/form-data";
WebOperationContext.Current.OutgoingResponse.Headers["Accept"] = "multipart/form-data";
}