Tag Archives: ASP.NET Web API

Web Api Progressive Download on GitHub and NuGet

In a previous post I wrote an example library for ASP.NET Web Api that would handle HTTP requests that could contain RANGE headers. I just published the code on GitHub and have made a signed, release build package on NuGet.

You can find usage information in the Progressive Download GitHub repository. The latest build is dependent on the WebApi Client and Core version 5.0.0 NuGet packages and the Newtonsoft.Json version 4.5.11 NuGet package. Hopefully this will let people leverage the library without upgrading their dependencies.

The solution on GitHub contains 100% code coverage tests which I’ve been running before I commit the code or publish a package to NuGet.

Check the previous post on the topic about limitations of the System.Net.Http.ByteRangeStreamResult class or any other particulars. I would recommend this path for progressive downloads than my aging attempts to replicate the functionality in MVC.

Feedback is welcome.


Progressive Download Support in ASP.NET Web API

(Update 2014-12-10: The code is now in GitHub and a package is available as a NuGet Package. See the announcement about it.)

Some time ago I read an interesting Stack Overflow question asking about streaming videos to iOS devices from ASP.NET MVC. In researching the answer, I learned about parsing HTTP request headers and constructing responses. In general for iOS devices to support playing video a web server needs to understand requests with the RANGE header and respond appropriately with 206 (PartialContent) and a CONTENT-RANGE header which more or less repeats the original request range.

I originally wrote an answer to this effect but also wanted to test it out to make sure it worked in ASP.NET MVC. While successful, it was not particularly elegant. After getting some feedback and requests, I wrote a second version. Surprisingly I still get pings on this from time to time and it made me wonder if something more integrated has shown up in ASP.NET MVC since my original attempts. Until recently I hadn’t had a need for this myself until a couple days ago I got the urge to stream video content from my Windows laptop to my TV and thought this might be a good time to revisit the library. What I wanted was an iOS compliant video server so I could stream videos to my Apple TV via my phone.

I knew I had a working library for ASP.NET MVC that I could have up and running in a few minutes but I was more curious if there had been any advancements in supporting partial range requests more seamlessly. A few brief searches turned up the ByteRangeStreamContent class and the HttpRequestMessage’s RANGE header used in ASP.NET Web API which looked promising.

Continue reading