Asked by:
Web API 2 Fastest way to transfer bytes array from webapi MVC 5 to ASP.NET Core 2

Question
-
User-1350516731 posted
Hello all!
How could I do really fast HTTP GET file transfer from webapi 2 to core 2? Please, provide complete example of async webapi method. I'm using .NET Framework 4.7.2.
Thank you for your assistance!
Best regards
Friday, May 24, 2019 7:30 PM
All replies
-
User1120430333 posted
The fastest means in data transmission is binary. So, I suggest that you find a binary example using ASP.NET WebAPI.
Friday, May 24, 2019 8:00 PM -
User475983607 posted
How could I do really fast HTTP GET file transfer from webapi 2 to core 2? Please, provide complete example of async webapi method. I'm using .NET Framework 4.7.2.
Should we assume the requirement is to transfer a file using C# over HTTP; multipart/form-data?
https://stackoverflow.com/questions/16416601/c-sharp-httpclient-4-5-multipart-form-data-upload
The ASP.NET Core docs explain how to handle file uploads. I recommend you read the openly published documentation and select an option that best fits your requirements.
https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-2.2
Please show the code that you have written up to this point, explain any issues you are having as well as what "really fast" means.
Friday, May 24, 2019 8:19 PM -
User-474980206 posted
MVC 5 is the real bottleneck as it is much slower than MVC core. the faster file retrieval would be to use IIS static file handler instead of MVC, but if you use MVC then something like:
public class DownloadsController : Controller { public FileResult File(string path) { var fullPath = HostingEnvironment.MapPath(path); return File(fullPath, "content-disposition"); } }
Friday, May 24, 2019 10:34 PM -
User-1350516731 posted
Hello!
I'm trying to use this sample:
https://stackoverflow.com/a/9549889
I have the bytes in stream but there are Content-Length:0 and empty body in Response.
Saturday, May 25, 2019 10:11 AM -
User475983607 posted
There must be a bug in your code. Share your code if you need help debugging.Saturday, May 25, 2019 10:51 AM