@Max I am not familiar with the website_chunked_transfer application setting. Upon reviewing the list of approved application settings, I do not see it listed there. With PaaS products, not all items may work as they do on a local instance.
I would argue that there are better ways to serve media in Azure such as using Azure CDN but I will provide a below sample if you wish to go via the Web App route.
To chunk data on an Entity Framework web app for video streaming within a web app, you can use the Range
header in the HTTP request to request a specific range of bytes from the video file. This allows you to send the video file in small chunks, which can be streamed to the client as it is received.
Here's an example of how you can implement this in your Entity Framework web app:
- In your controller action that serves the video file, check if the
Range
header is present in the HTTP request. If it is, parse the range values to determine the start and end byte positions of the requested chunk. - Open a
FileStream
to the video file and seek to the start position of the requested chunk. - Read the requested chunk of data from the
FileStream
and write it to the HTTP response stream. - Set the
Content-Range
header in the HTTP response to indicate the byte range of the requested chunk. - Set the
Content-Length
header in the HTTP response to indicate the length of the requested chunk. - Set the
Content-Type
header in the HTTP response to the appropriate MIME type for the video file.
Here's some sample code to get you started:
public IActionResult GetVideo(string videoId)
{
// Get the path to the video file
string videoPath = GetVideoPath(videoId);
// Open a FileStream to the video file
using (FileStream videoStream = new FileStream(videoPath, FileMode.Open, FileAccess.Read))
{
// Check if the Range header is present in the HTTP request
if (Request.Headers.ContainsKey("Range"))
{
// Parse the range values to determine the start and end byte positions of the requested chunk
string rangeHeader = Request.Headers["Range"].ToString();
long start = long.Parse(rangeHeader.Substring(rangeHeader.IndexOf('=') + 1, rangeHeader.IndexOf('-') - rangeHeader.IndexOf('=') - 1));
long end = long.Parse(rangeHeader.Substring(rangeHeader.IndexOf('-') + 1));
// Seek to the start position of the requested chunk
videoStream.Seek(start, SeekOrigin.Begin);
// Calculate the length of the requested chunk
long length = end - start + 1;
// Write the requested chunk of data to the HTTP response stream
Response.StatusCode = 206; // Partial Content
Response.Headers.Add("Content-Range",