I have C # in a utility for a web API project. The code loading part is working fine; I checked the file that gets to the server matches the downloaded file. However, something happens in the download that causes the client to view the file as damaged, and when I do the diff, I see that something went wrong.

Unfortunately, I cannot understand what I am doing wrong. The relevant parts of the utility are as follows:
public static HttpResponseMessage StreamResponse(this HttpRequestMessage request, Stream stream) { if (stream.CanSeek) stream.Position = 0;
My use in API controllers return ResponseMessage(Request.StreamResponse(stream).DownloadAs("Filename.ext"));
I have double-checked code to download, and it looks like what I found. What am I doing wrong or what am I missing? There seems to be something wrong with the encoding or encoding, but I cannot say what the solution is.
c # asp.net-web-api download
ricksmt
source share