c# - ECONNRESET for response.write 不时返回邮递员
问题描述
我正在使用 asp.net 2.0 ashx 页面,该页面在服务器端和客户端邮递员方法中有此代码:
try {
if (Request.RequestType == "GET")
{
//..
}else if (Request.RequestType == "POST"){
if (restMethod == "PostSomeAction"){
//some code ...
if (pifFirma == null){
MyCustomResponse myCustomResponse = new MyCustomResponse();
myCustomResponse.Code = "NoFirmFound";
myCustomResponse.Message = "No firm was found incoming ip address";
Response.Write(JsonConvert.SerializeObject(myCustomResponse));
Response.StatusCode = (int)HttpStatusCode.Forbidden;
Response.ContentType = "application/json";
//Response.Flush() //it seems this line gives always ECONNRESET
return;
}
//..rest of code
}
}
}catch (Exception ex){
MyCustomResponse myCustomResponse = new MyCustomResponse();
myCustomResponse.Code = "ErrorOccured";
myCustomResponse.Message = "Some Error Occured";
Response.Write(JsonConvert.SerializeObject(myCustomResponse));
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
Response.ContentType = "application/json";
return;
}
在邮递员处,当我向“PostSomeAction”发布操作时,它会不时地给 ECONNRESET 时间并有时返回 json 消息。
似乎当我取消注释 Response.Flush() 时,它似乎总是 ECONNRESET 但不确定。
另一方面,可能在 catch 执行中的 I 代码处,它成功返回 json 消息。
最后,当代码到达末尾没有任何“返回”时,它似乎总是成功返回 json 消息
在上述情况下,邮递员收到 ECONNRESET 消息的原因是什么?如果 ssl 是问题,它不应该总是出错。怎么可能“回归”表达因素呢?
解决方案
推荐阅读
- javascript - 如何可靠地将 base_url 从 Codeigniter 传递给 JavaScript?
- sql-server - 当您编写列级权限脚本时,SSMS 18.4 是否存在错误?
- r - Shiny 间接选择输入并显示组
- amazon-web-services - AWS Lambda 负载响应
- json - jq - 如果不包含则过滤 JSON 数组不起作用
- javascript - 无法读取未定义的“id”属性
- python - 简单微分方程的问题求解和绘图解
- javascript - 为什么我不能在 VueJS 中按下我的单选按钮?
- node.js - 如何获取打字稿文件的路径,而不是编译后的 javascript?
- javascript - 如何在动态手风琴列表上一次只打开一个手风琴项目?