Uploading Big Files in ASP.NET Core

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we are going to learn how to upload big files into Xperia net core if you don't configure sbl Network correctly you are going to have issues when trying to upload big files so let's see our sample application it is a really simple application we have here choose file which is a input type file let me choose a file I will choose this PDF which is of size 8 megabytes so let me press enter then I will click on send and what the application is going to do is to send that file into a controller and then it's going to Output the file size really simple application but now if I choose the order file which is a big file of 258 megabytes you are going to see that we are going to have an error let's press send and let's see that here you have an exception so let's see the code of the application and let's see how to solve this alright so let's go to visual studio as you can see here we have the form we have multiplier four date data so that we can send files we have our input type file here and our send button and then in here I have that if we have the file size then we're going to display this paragraph here and in the controller in the home controller we have these HTTP post action here which receives the file as an iPhone file calculates the file size in megabytes and then it returns that again pretty simple stuff so what we're going to do now is that we're going to remove that limit that xplnet core imposes on us by default regarding the file size so we have to wait to proceed we can do this locally or we can do that globally we're going to start locally so let's say that I only want to increase the limit of the file size here in this action so for that I'm going to say request size limit and then let's say that I want 512 megabytes so for that I would say 512 times 10 24 times 10 24 after that I have to come to the program class let's come to the program class and in here before this bar up I need to say the following and let me say Builder Services configure form options options semicolon here and then let me say options multi-part body length limit and I will put here again 512 megabytes so times 1024 time 10 24 semicolon here and that's it with this I'm good to go let me press Ctrl F5 to run my application and let's come back here and we're going to see that this will refresh automatically and we're going to see that we will have 258 megabytes but if I want to I can refresh and start from the beginning let me select this file here and then send it may take a few seconds but after that we're going to have 258 megabytes now if I don't want to solve this problem locally let's say that I want to have this configuration that I have here this configuration globally then I can do the following I can comment this out because we're not going to need it anymore and then I can come back to the program class configure Castrol itself the web server so that it can handle a body size of 512 megabytes so let me say here Builder web host configure Castrol options and then options limits Max request body size and again I'm going to put this here of course 512 megabytes is just an arbitrary number that I chose you can choose a bigger limit or a lower limit and it doesn't matter so now that we have this and remember that I remove this from here let me press Ctrl F5 one more time so you can see that now this configuration has been done globally Let me refresh and let's go from the beginning let me say here this one send and you are going to see that again we have 258 megabytes here if you want to learn more about.net buy my udemy courses today I have courses on building apps with experience core and react building apps with a speedo net core and angular programming in c sharp from beginner to Advanced and more link with a discount to all of my courses in the description of this video thank you
Info
Channel: gavilanch3
Views: 3,400
Rating: undefined out of 5
Keywords:
Id: ollScUHiFKs
Channel Id: undefined
Length: 4min 40sec (280 seconds)
Published: Wed May 31 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.