Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm using a Customizable-Embedded-HTTPServer for a project. Simply I'm calling response.SendFile(@"E:\folder\xx.mp4", "video/mp4") to play video files located at local folder. But it gives me "An existing connection was forcibly closed by the remote host" error. I've searched a lot but couldn't find a solution!

using (FileStream fs = File.OpenRead(path))
                    this.Date = File.GetLastWriteTime(path);
                    this.ContentLength = fs.Length;
                    this.ContentType = mediaType;
                    this.ChunkedTransferEncoding = false;
                    _stream = new HTTPOutputStream(_session);
                    int rc;
                    byte[] bytes = new byte[65536];
                        rc = fs.Read(bytes, 0, 65536);
                        _stream.Write(bytes, 0, rc);
                    } while (rc != 0);

Embedded http server project is taken from ;
C# Customizable Embedded HTTPServer[^]
Updated 23-Mar-15 23:01pm
kubibay 24-Mar-15 8:20am    
any idea??
kubibay 25-Mar-15 4:56am    
When I debug I noticed that it is entering SendFile method more than once somehow, this can be the issue, but I don't know why that happens. Another question with this method I can't jump to forward in the video, how can I do that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900