Skip to content

Return File in ASP.NET Core Web API: move the sample to .NET 10 - #2262

Merged
vladimir-pecanac-main merged 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/74385-aspnetcore-web-api-return-file
Oct 5, 2026
Merged

vladimir-pecanac-main merged 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/74385-aspnetcore-web-api-return-file

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Updates the sample for "Return File in ASP.NET Core Web API" (https://code-maze.com/aspnetcore-web-api-return-file/). Only aspnetcore-webapi/ReturnFileWebApi changes.

  • Both projects retargeted from net6.0 to net10.0.
  • Swashbuckle.AspNetCore 6.2.3 removed; Microsoft.AspNetCore.OpenApi 10.0.12 added with AddOpenApi() and MapOpenApi(). launchUrl now points at openapi/v1.json, since the Swagger UI no longer exists.
  • Moq 4.18.2 replaced by NSubstitute 6.2.0 (Moq 4.20.0 shipped SponsorLink telemetry).
  • Test packages: Microsoft.NET.Test.Sdk 18.10.1, xunit 2.9.3, xunit.runner.visualstudio 4.0.0, coverlet.collector 10.1.0.
  • The two tests now assert FileContentResult / FileStreamResult plus ContentType and FileDownloadName instead of NotNull; a third test covers EnableRangeProcessing.
  • New: images-stream-range action (enableRangeProcessing: true) and a minimal API endpoint /minimal/images-stream using Results.File.
  • File-scoped namespaces, a primary constructor on DownloadsController, two unused usings removed.

Package versions re-queried on NuGet on 2026-10-04 (newest stable): Microsoft.AspNetCore.OpenApi 10.0.12, Microsoft.NET.Test.Sdk 18.10.1, xunit 2.9.3, xunit.runner.visualstudio 4.0.0, coverlet.collector 10.1.0, NSubstitute 6.2.0.

Local: SDK 10.0.302, runtime 10.0.10. dotnet build -c Release: 0 warnings, 0 errors. dotnet test: Passed 3, Failed 0. dotnet list package --vulnerable --include-transitive: clean.

Retarget both projects to net10.0, replace Swashbuckle with
Microsoft.AspNetCore.OpenApi, swap Moq for NSubstitute, bump the test
packages, assert the concrete file result types in the tests, and add
the range-processing action and the minimal API endpoint the article
now shows.
@vladimir-pecanac-main
vladimir-pecanac-main merged commit fc4955c into CodeMazeBlog:main Oct 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant