使用C#中的web api输出流 [英] Output streaming using web api in C#
问题描述
需要创建一个Web API来读取json文件并将输出写入流。
我尝试过:
[ApiController]
公共类ValuesController:ControllerBase
{
/ / GET api / values
[HttpGet]
公共对象Get()
{
string allText = System .IO.File.ReadAllText(/ data.json);
对象jsonObject = JsonConvert.DeserializeObject(allText);
返回jsonObject;
}
}
这只输出json文件..我会做数据流。
A web API need to be created to read from a json file and write output to stream.
What I have tried:
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public object Get()
{
string allText = System.IO.File.ReadAllText("/data.json");
object jsonObject = JsonConvert.DeserializeObject(allText);
return jsonObject;
}
}
this only outputs json file..how will i do data streaming.
推荐答案
如果谈论asp.net核心,这个搜索有一些有趣的结果: asp.net核心大型响应文件 - Google搜索 [ ^ ]
* 在ASP.NET Core 2.0中上传/下载文件 - Tahir Naushad的博客 [ ^ ]
* 在ASP.NET核心上播放Zip [ ^ ]
* ASP.NET Cor中的内容e [ ^ ]
If talking asp.net core, this search has some interesting results: asp.net core large response files - Google Search[^]
* Upload/Download Files in ASP.NET Core 2.0 – Tahir Naushad's Blog[^]
* Streaming Zip on ASP.NET Core[^]
* Streaming Content in ASP.NET Core[^]
这篇关于使用C#中的web api输出流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!