ASP MVC open a live stream between remote host and the connected user

Constantin446

New Member
The idea is simple, i am creating a service where user can put the direct link of a file that is being hosted on another website and my program will open a stream to that remote server and start reading the file in bytes and then return each readed byte to the user.Example :Internet download manager will go to my page, then my code will fetch the remote file and read it in bytes and return each byte to Internet download manager to download the file.here is my code\[code\] public void Index() { using (WebClient wcDownload = new WebClient()) { try { // Create a request to the file we are downloading HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://FILE-IS-NOT-ON-MY-SERVER.com/file.zip"); // Set default authentication for retrieving the file webRequest.Credentials = CredentialCache.DefaultCredentials; // Retrieve the response from the server HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); // Ask the server for the file size and store it Int64 fileSize = webResponse.ContentLength; // Open the URL for download Stream strResponse = wcDownload.OpenRead("http://FILE-IS-NOT-ON-MY-SERVER.com/file.zip"); // It will store the current number of bytes we retrieved from the server int bytesSize = 0; // A buffer for storing and writing the data retrieved from the server byte[] downBuffer = new byte[500000000]; // Loop through the buffer until the buffer is empty while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0) { // i want to return each byte to the user for example Internet Download Manager } // When the above code has ended, close the streams strResponse.Close(); } catch (Exception) { } } }\[/code\]i know it is messy but i really don't know how to return each byte to the user.
 
Top