samonzeweb / send-file-aspnetcore

How to send a file with ASP.NET Core (multiple ways)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Illustration of the different ways to send file content with ASP.NET Core

What ?

The SendFile controller show different ways to send a file (or custom content).

How to run this code

The code was writen using ASP.NET Core 2.1 Preview 1, but should be compatible with ASP.NET Core 2.0. Just clone the repository and execute dotnet run from the command line.

You can use curl to call the different actions, and see the response details (Windows users could use WSL or Git Bash) :

To go deeper

Not all example behave the same, some response headers could be set or not, some request headers could by used, ... To know all the details, see ASP.NET Core source code.

Exemple with PhysicalFileResult and related parts :

About

How to send a file with ASP.NET Core (multiple ways)


Languages

Language:C# 100.0%