【发布时间】:2016-12-20 13:49:47
【问题描述】:
当我将此文件保存在磁盘上时,我试图输出一个“非常长”的 Json 字符串,它是 405KB,但我想通过 Response.Write 将它提供给客户端,但由于某些奇怪的原因并没有输出字符串已填充。 这是一个没有 MVC 的简单 ASP.NET 网页 当我使用
// Clear out the buffer
Response.ClearHeaders();
Response.ClearContent();
Response.Clear();
// Do not cache response
Response.Cache.SetCacheability(HttpCacheability.NoCache);
// Set the content type and encoding for JSON
Response.ContentType = "application/json";
Response.ContentEncoding = Encoding.UTF8;
Response.Write(strJsonData);
// Flush the response buffer
Response.Flush();
// Complete the request. NOTE: Do not use Response.End() here,
// because it throws a ThreadAbortException, which cannot be caught!
HttpContext.Current.ApplicationInstance.CompleteRequest();
它不会在我的屏幕上显示响应。
我尝试了什么: 网页配置
<httpRuntime maxRequestLength ="999999999" requestValidationMode="2.0" />
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="999999999" />
</requestFiltering>
</security>
</system.webServer>
【问题讨论】:
-
错误信息是什么?
Response.Write是关于传出,requestLimits是关于传入数据 -
ondisk是什么意思?那你想把字符串保存在服务器上吗?还是说你真的是想给客户端发送一个 Json 结果? -
我的意思是当我将文件保存在磁盘上 405kb 时文件本身是但我想用 Response.Write 向客户端响应它但它不起作用但 JsonResult 已填充。
-
这是什么网站? Web 表单,MVC?
JsonResult是什么?是你的字符串的名字吗?它有内容吗?你是怎么填的? -
Exaclty fubo 但字符串中填充了正确的序列化 JSON 数据