I have a problem delivering videos in .NET Core. I'm getting a video file by an absolute path and returning it to be used as a source in a element. However, I'm enabling HTTP Range requests by passing enableRangeProcessing: true to the method, and after fast seeking through the video (once it's loaded) the action stops providing responses. The response contains exactly 16.1kb of data and does not contain any response preview or response content at all.
Reloading the page after that does not help, the only thing that fixes it is rebuild and rerun again, or sometimes if you wait a while (2-3 minutes) the video loads normally on reload.
More often than not it happens when you load a video initially (preferably a longer one, the videos i'm trying to display are actually movies from my PC) and then try to "seek" through the video in quick succession. I'm seeing about 100-150 requests in DevTools (most of them cancelled, but still). After that, the requests stop responding with parts of the movie. Again, this does not happen every time and sometimes the issue disappears after 2-3 minutes.
Here's a link to a video capturing the issue. As described above, about 3 minutes after I stopped recording the video loaded normally.
The action in question
public IActionResult GetVideo(string path) {
path = Uri.UnescapeDataString(path);
return PhysicalFile(path, "application/octet-stream", enableRangeProcessing: true);
}
And here's the front-end side
<video src="@Url.Action("GetVideo", "Home", new { path = ViewBag.Id })" controls></video>
The path variable is an URI-escaped string of the absolute path in my system (for debugging purposes, it will be through IDs in the future.
When trying with virtual paths (place a mp4 file in the wwwroot folder), the issue is no longer present but I'd like to be able to deliver the videos from physical paths.
Does anyone know what might be causing this?