Hi Daniel Cooper,
Thanks for clarifying the sequence.
The fact the video works in production (Azure) but fails locally suggests that there's a difference in how static files, especially videos which use byte-range requests, are processed by MapStaticAssets() versus your local hosting pipeline (Kestrel). There's a known issue reported in the ASP.NET Core repo titled "MapStaticAssets returns incorrect Content-Length for custom Range". The issue link is:
https://github.com/dotnet/aspnetcore/issues/63320
(Disclaimer: Some links are non-Microsoft website. The pages appear to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classifies as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it. )
In that issue, a video file served via MapStaticAssets() caused a mismatch between Content-Range and Content-Length, which breaks playback in some browsers.
Here's a more targeted workaround you can test locally:
- In your server project's
.csproj, exclude the .mp4 video file(s) from static-web-asset processing:
<ItemGroup>
<Content Update="wwwroot/videos/**/*.mp4"
CopyToOutputDirectory="PreserveNewest">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
<ItemGroup>
<StaticWebAsset Remove="wwwroot/videos/**/*.mp4" />
</ItemGroup>
- Run locally and check whether the video plays. If yes, then you've effectively sidestepped the issue locally by letting
UseStaticFiles()serve the video. - For confirmation, open your browser's Developer Tools → Network tab, request the video and inspect the headers:
- Check if the request has a
Rangeheader - Check if the response has
Accept-Ranges: bytes - Check if
Content-Rangeis present and ifContent-Lengthmatches the range length (rather than full file size). IfContent-Lengthequals full file size despite a partial request.
- Check if the request has a
Hope this helps!