When we want to serve a file (non HTML) from an action we can use the File Action Result. The contructor can accept either a byte[] or a Stream. Which one is better? Why?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would use a stream and I would try hard to stream data down to the client without ever load all data into a
byte[]on the web server.This is the only way you are sure you do not load files completely in the server memory, imagine 10 people downloading files of 100 Mb each, better to avoid the ASP.NET process to grow to 1GB RAM only because of that, with streaming you can do this 🙂