Streaming Video files

Topics: Web Api
Jan 20, 2012 at 1:00 PM


Is it recommended to use WCF Web APIs for streaming (System.IO.Stream) large video files?

Are there any good examples on how to do this?


Jan 21, 2012 at 3:13 PM
Edited Jan 21, 2012 at 3:16 PM

Anybody there?

I am trying to convert a gblock written code( to work with the APIs.

My code so far looks like below

    public class VideoResource

        [WebGet(UriTemplate = "")]
        public Stream Get()
            FileStream stream = new FileStream(@"C:\Users\Public\Videos\Sample Videos\Wildlife.wmv", FileMode.Open, FileAccess.Read);
            return stream;

and my global.asax is 
 protected void Application_Start(object sender, EventArgs e)

I am not using any HTTPConfiguration stuff yet.
When I looked at gblock's old code, response content-type is application/octet-stream.
I am not sure if I need to add a mediaformatter. If it's the case what's it's implementation?
web.config is -
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2147483647"/>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" messageEncoding="Mtom"/>


please help.