-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
@@ -41,6 +41,7 @@ internal enum PreconditionState | |||
ActionContext context, | |||
FileResult result, | |||
long? fileLength, | |||
bool enableRangeProcessing, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is .Infrastructure considered public API? the class is public and the method is protected, so people could derive from it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was .Internal until recently.
@Eilon is Infrastructure just a name change and is considered internal still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbagga was this in .Infrastructure
in 2.0.0? That's the salient point
If this class was in .Internal
in 2.0.0 then it has no support bar in 2.0.0 and there is no breaking change 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or rather, it's a change that we're willing to make
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was .Internal in 2.0.0 https://github.com/aspnet/Mvc/blob/rel/2.0.0/src/Microsoft.AspNetCore.Mvc.Core/Internal/FileResultExecutorBase.cs#L16
So I'll merge this in!
@Eilon since .Infrastructure is a public namespace, this is a breaking change Edit: This was .Internal in 2.0.0, so it isn't a breaking change. Merging it in |
@jbagga - Could you please confirm if range processing, to enable 206 Partial Content responses, will not be in ASP.NET Core until 2.1, which has yet to be released? Reason I'm asking is because the online documentation here for ASP.NET Core 2.0 - which I'm currently using - seems to imply that this is already implemented:
Intellisense within Visual Studio is similarly mentioning support for range requests when working with File Result Executors (e.g. Thanks in advance for your help! |
@spallister It should work for 2.0.0 by default. Can you share a repro and the exact SDK you are using? In 2.0.x patch we added a switch to turn on range processing #6792 (not ON by default). |
@jbagga - I was using ASP.NET Core 2.0.3, then just tried updating to ASP.NET Core 2.0.5, and see that I'm using 2.1.4 of the .NET Core SDK upon running Here's the action that I'm trying to execute: /// <summary>
/// Get Video File by ID.
/// </summary>
[HttpGet("{id}/file")]
public async Task<FileStreamResult> GetVideoFileById(Guid id)
{
var query = new GetVideoFilePathQuery(id);
var videoFilePathDto = await _mediator.Send(query);
if (videoFilePathDto != null)
{
return File(System.IO.File.OpenRead(videoFilePathDto.FilePath), videoFilePathDto.FileContentType);
}
else
{
return null;
}
} I was able to successfully return 206 Partial Content responses using a SO contributor's VideoStreamResult implementation here (e.g. replaced For the switch you mention in your above post, how do I go about enabling it (i.e. where is it located)? |
You can set the switch like this example in a runtimeconfig.json file for .NET Core
This will turn on range processing for Edit: For dev and 2.1.x, using an overload of File with |
That's got it - Thanks, @jbagga! I ended up setting the switch programmatically in Program.cs: // Enable 206 Partial Content responses to enable Video Seeking from api/videos/{id}/file,
// as per, https://github.com/aspnet/Mvc/pull/6895#issuecomment-356477675.
// Should be able to remove this switch and use the enableRangeProcessing overload of File once
// ASP.NET Core 2.1 released
AppContext.SetSwitch("Switch.Microsoft.AspNetCore.Mvc.EnableRangeProcessing", true); |
Addresses #6780
Ensured that this change solves the multiple GET requests issue described in #6780.
@Tratcher @rynowak