我正在使用Asp.Net核心Azure Web應用程序向客戶端提供RESTful API,並且客戶端無法正確處理分塊。在Asp.Net Core中禁用分塊
是否有可能在控制器級別或web.config中完全關閉Transfer-Encoding: chunked
?
編輯:我有點返回JsonResult這樣的:
[HttpPost]
[Produces("application/json")]
public IActionResult Post([FromBody] AuthRequest RequestData)
{
AuthResult AuthResultData = new AuthResult();
return Json(AuthResultData);
}
你有沒有在響應中的 「內容長度」 標頭? –
我已經添加了一個我的動作看起來像的例子。我不添加那個標題,因爲我不知道Json製作的時間會多長。以前,ASP已經添加了該標題,但在最近的服務器中不再使用(可能是因爲遷移到了RC2) –
您可以使用響應緩衝來執行此操作:https://github.com/aspnet/BasicMiddleware/blob/dev/samples /ResponseBufferingSample/Startup.cs#L17 – Tratcher