WebAPI support for File based Partial Content 206
Asp.net core support for partial content is far out easier than i imagine. For example, if your application delivering a huge file, 100 Megabytes for example. then you might want to request these data as chunks
Some notes : this only works for File result and not with JSON which might fetch some data from the table. For example, you have a huge json (about 2M) and defining range 30-1000 will not change returned data.
Sample controller to handle partial content :- Yeap this is all you need.
Next, fire up your post and and you can see some of the results that i'm getting. Oh before anything else, please ensure you place a large txt file a folder.
As you can see from Postman. i create a request with Range : 30 - 1000 and the response is shown here too.
A couple of things to notice :-
Return result is 206. (Http Partial Content)
Content-Length is 2500 ( which is the total file size we have)
Some notes : this only works for File result and not with JSON which might fetch some data from the table. For example, you have a huge json (about 2M) and defining range 30-1000 will not change returned data.
Sample controller to handle partial content :- Yeap this is all you need.
Next, fire up your post and and you can see some of the results that i'm getting. Oh before anything else, please ensure you place a large txt file a folder.
As you can see from Postman. i create a request with Range : 30 - 1000 and the response is shown here too.
A couple of things to notice :-
Return result is 206. (Http Partial Content)
Content-Length is 2500 ( which is the total file size we have)
Comments