public static HttpResponseMessage ConvertStreamToResponseType(this System.IO.Stream stream, string mediaTypeHeaderValue) { stream.Position = 0; var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(stream) }; response.Content.Headers.ContentType = new MediaTypeHeaderValue(mediaTypeHeaderValue); return response; }
447700cookie-checkC# WebAPI Return Stream As Response