File Download from ASP.NET 5.0 Web API [With only one line of code]

  Рет қаралды 23,308

DotNet Core Central

DotNet Core Central

Күн бұрын

In this video, I am going to walk through how we can use out of box features of ASP.NET 5.0 Web API to allow file download from an ASP.NET Core Web API Application.
In this video, I will cover a couple of topics:
1. Create an HTTP GET method in Web API to allow file download (a CSV file)
2. Create an HTML/JavaScript page to allow calling of the Web API to download the CSV file
In this video, I will be using the Static file feature of ASP.NET Core. I have done a video in the past to explain how to expose static files in ASP.NET code, here is the link to that video: • How to serve Static Fi...
The URL to my website is: dotnetcorecent...
The URL to my GitHub repo is: github.com/cho...
If you want to buy me a coffee, you can visit this: www.buymeacoff...
Few of my popular downloads:
C# 9 Features: • My favorite new featur...
RabbitMQ with .NET Core: • RabbitMQ in .NET Core ...
Ocelot API Gateway: • How to build an API Ga...

Пікірлер: 54
@danielberry9610
@danielberry9610 3 жыл бұрын
Thanks for the vid. I couldn't get this to work in .NET 6 using the old methods. This works great!
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Daniel Berry, Thanks for watching!
@brow318
@brow318 2 жыл бұрын
This solution was instrumental to helping me write XML files. Thanks so much.
@DotNetCoreCentral
@DotNetCoreCentral 2 жыл бұрын
Thanks for watching!
@davimezalira
@davimezalira 3 жыл бұрын
Thanks...your tutorials about .net webapi is the best
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Davi Mezalira, thanks!
@goodmanshawnhuang
@goodmanshawnhuang 3 жыл бұрын
thanks for sharing this, that's exactly what I am looking for the solution to dynamically generate a file. thanks a lot.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Shawn Huang, thanks for watching!
@rongliao9255
@rongliao9255 3 жыл бұрын
Very helpful tutorial! Especially covering the new .NET 5.0, great content!
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Rong Liao, thanks for watching!
@aj.arunkumar
@aj.arunkumar 4 жыл бұрын
awesome man... i always wondered about how file download would be implemented but never explored it...
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Arun Kumar A.J, thanks for watching!
@emresun
@emresun 3 жыл бұрын
Great video, easiest way to download a file from asp.net web api.. Thank you..
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Emre Sunar, thanks for watching!
@vj1012
@vj1012 4 жыл бұрын
Very Informative and nicely eplainined.
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@vj1012, thanks for watching the video!
@fanpeter-z3c
@fanpeter-z3c 3 жыл бұрын
that's sick, I have been trying very old answers from stackOverflow, none of them works, your answer should be updated in there
@phelipelima4230
@phelipelima4230 Жыл бұрын
but what if my method that returns the file its a POST method instead of a GET?
@pieteb_nl
@pieteb_nl 2 жыл бұрын
Thanks man! Very to the point
@DotNetCoreCentral
@DotNetCoreCentral 2 жыл бұрын
Thanks!
@TheOMarsawy
@TheOMarsawy 2 жыл бұрын
You saved me Thank you!!!!!!!
@bohirjonakhmedov
@bohirjonakhmedov 3 жыл бұрын
what if you want to make your controller authorized?
@aethenwulf4757
@aethenwulf4757 2 жыл бұрын
how about a download button that will let you choose a file path / rename the file / save as ?
@辰-g4i
@辰-g4i 3 жыл бұрын
I appreciate you to update this video. I want to humbly ask u that is it possible to use this to let phone get the file in pc?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@辰, thanks for watching! I will try to get the video in full HD to be phone-friendly.
@辰-g4i
@辰-g4i 3 жыл бұрын
@@DotNetCoreCentral It’s nice of you 👍 I’m looking forward to your video.
@muhammedalitunc219
@muhammedalitunc219 3 жыл бұрын
You are amazing thank you
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Muhammed Ali Tunç, thanks for watching!
@viktorrimoru797
@viktorrimoru797 4 жыл бұрын
Doing a great job man! Thanks alot!
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Viktorr IMORU, thanks for watching!
@harishkommuri5350
@harishkommuri5350 4 жыл бұрын
It was fantastic video, could you make a video on - How a webApi/webApplication(.net core, mvc) handles the requests with multiple servers and a load balancer in front, I'm more looking into what happens If one of the server that served a request or generated a token for a user went down, wt will happen to user, will he be logged out? I was asked in a Interview I couldn't it explain it more...
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Harish Kommuri, thanks for watching the video. In terms of your question, the user credentials are usually kept in an out of process storage like a database, and the token is usually kept in an out of process cache. So even if a single server goes down, when the request goes to another server, it is still able to validate the user.
@SuperSridar
@SuperSridar 3 жыл бұрын
Good. In my case I want to download a large file. Say 500 MB. How to download it chunk by chunk instead of downloading as a whole.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Shridhara Gowda, thanks for watching! If you need to create a chunk of data then that logic needs to be handled in the service and you will need to send back the total number of files that you will have to the caller with some ID's so that you can return back them the chunk later, and you will probably need to either save the chunk somewhere to return later or just manage it in memory.
@ptlh1969
@ptlh1969 4 жыл бұрын
Nice... thanks. :)
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Peter Toh, thanks for watching!
@mahendranchinnaiah7593
@mahendranchinnaiah7593 4 жыл бұрын
Thanks much..
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Mahendran Chinnaiah, thanks for watching!
@arjunm.r8641
@arjunm.r8641 3 жыл бұрын
@Dotnet core central can I do this for downloading a pdf from http url using asp.net core mvc with asp.net core web api ?Hope you understand my question
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Arjun m.r, yes, it should work.
@eliassal1
@eliassal1 4 жыл бұрын
Another nice and useful video, great. I was about to get 3 coffees but while doing the visa card payment it seems that we should create a Paypal account which I don't like as it is not so safe
@DotNetCoreCentral
@DotNetCoreCentral 4 жыл бұрын
@Salam Elias, thanks for watching the video!
@rizkyfardiansyahtanjung8863
@rizkyfardiansyahtanjung8863 3 жыл бұрын
Hello Sir, How to download multiple file in asp net core?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Rizky Fardiansyah Tanjung, for multiple file downloads, you can zip them together and download.
@rizkyfardiansyahtanjung8863
@rizkyfardiansyahtanjung8863 3 жыл бұрын
@@DotNetCoreCentral do you have any tutorials about this, sir?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@@rizkyfardiansyahtanjung8863 no I dont have, but I can make one in the future.
@svens3722
@svens3722 3 жыл бұрын
does this also work with music files, for example wav? Great tutorial btw.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Sven s, thanks for watching! I have not tried with wav or other extensions, but I don't see why not, might have to try it out.
@svens3722
@svens3722 3 жыл бұрын
@@DotNetCoreCentral wow fast response :D, yes im currently on trying. i will tel you in a few minutes. Thanks for your effort =).
@svens3722
@svens3722 3 жыл бұрын
@@DotNetCoreCentral wow it worked, i love you.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@@svens3722 awesome!
@thanitkonmek4478
@thanitkonmek4478 3 жыл бұрын
can't download file bigger then 2GB
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Thanit Konmek, I never tried to download such a big file. I will have to investigate where is the issue. If it is not supported out of the box, then zipping should help, otherwise breaking the file into multiple downloads.
@mohammadrezamonshizadeh1528
@mohammadrezamonshizadeh1528 2 жыл бұрын
its not helpful
ASP.NET Core Crash Course - C# App in One Hour
1:00:44
freeCodeCamp.org
Рет қаралды 1,6 МЛН
Жездуха 42-серия
29:26
Million Show
Рет қаралды 2,6 МЛН
ВЛОГ ДИАНА В ТУРЦИИ
1:31:22
Lady Diana VLOG
Рет қаралды 1,2 МЛН
번쩍번쩍 거리는 입
0:32
승비니 Seungbini
Рет қаралды 182 МЛН
ASP.NET Web API - File Downloading - #14
7:15
AllTech
Рет қаралды 17 М.
📥 File Download with a .NET 6 Web API & Blazor WebAssembly
35:20
Build a RESTful API in ASP.NET 6.0 in 9 Steps!
12:32
tutorialsEU
Рет қаралды 88 М.
APIs Explained (in 4 Minutes)
3:57
Exponent
Рет қаралды 1,2 МЛН
Faulty Draper DMM200 Multimeter | Can I Fix It?
35:31
Buy it Fix it
Рет қаралды 6 М.
File upload and download in ASP .NET Core 6.0 Web API
8:05
Biswa Ranjan
Рет қаралды 28 М.
Жездуха 42-серия
29:26
Million Show
Рет қаралды 2,6 МЛН