Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net ExtJS:过快处理程序的响应有时会失败_Asp.net_Json_Extjs_Ashx - Fatal编程技术网

Asp.net ExtJS:过快处理程序的响应有时会失败

Asp.net ExtJS:过快处理程序的响应有时会失败,asp.net,json,extjs,ashx,Asp.net,Json,Extjs,Ashx,我有一个奇怪的问题,它并不总是出现,但有时有相同的要求。 在我的网站(localhost)上,我有一个自动加载的ExtJS存储,在页面加载(按F5按钮)后,它从服务器上的某个处理程序(*.ashx)读取JSON。处理程序从数据库获取数据并将其序列化为JSON。按F5键5次工作4次。第五次json阅读器显示success=false和0长度数据 如果我在处理程序中使用时间延迟,例如: System.Threading.Thread.Sleep(1000); 它的工作效率是50的49倍。但当我试图

我有一个奇怪的问题,它并不总是出现,但有时有相同的要求。 在我的网站(localhost)上,我有一个自动加载的ExtJS存储,在页面加载(按F5按钮)后,它从服务器上的某个处理程序(*.ashx)读取JSON。处理程序从数据库获取数据并将其序列化为JSON。按F5键5次工作4次。第五次json阅读器显示success=false和0长度数据

如果我在处理程序中使用时间延迟,例如:

System.Threading.Thread.Sleep(1000);
它的工作效率是50的49倍。但当我试图使网站更快时,在我的响应中设置延迟是很奇怪的

如果没有关于问题的足够信息,请帮助或询问我

以下是我的js示例:

storePrefixes.on({
        'beforeload': function () {
           //...
        },
        'load': {
            fn: function() {
                if (storePrefixes.data.items.length > 0)
                    // ... working with response
                else 
                    // here is a problem
            },
            single: true
        }
    });
还有服务器代码:

    <%@ WebHandler Language="C#" Class="GetPrefixesInRD" %>

using System;
using System.Web;
using BCR.BLL;

public class GetPrefixesInRD : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
{
    private readonly PrefixNewBLL prefixeBLL = new PrefixNewBLL();
    private readonly Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer();

    public void ProcessRequest(HttpContext context)
    {
        var prefixes = prefixeBLL.GetPrefixesByExistPrefixInAccountingDocs(null, 1, false);
        prefixes.Sort((x, y) => String.CompareOrdinal(x.Prefix, y.Prefix));

        context.Response.ContentType = "application/json";
        context.Response.Clear();
        context.Response.BufferOutput = true;
        serializer.Serialize(context.Response.Output, new { root = prefixes, total = prefixes.Count });
        context.Response.Flush();
        context.Response.End();
    }

    public bool IsReusable { get { return false; } }
}

使用制度;
使用System.Web;
使用BCR.BLL;
公共类getPrefixesNRD:IHttpHandler,System.Web.SessionState.IReadOnlySessionState
{
private readonly PrefixNewBLL prefixeBLL=new PrefixNewBLL();
private readonly Newtonsoft.Json.JsonSerializer serializer=new Newtonsoft.Json.JsonSerializer();
公共void ProcessRequest(HttpContext上下文)
{
var prefixes=prefixebl.GetPrefixesByExistPrefixInAccountingDocs(null,1,false);
前缀.Sort((x,y)=>String.CompareOrdinal(x.Prefix,y.Prefix));
context.Response.ContentType=“应用程序/json”;
context.Response.Clear();
context.Response.BufferOutput=true;
serializer.Serialize(context.Response.Output,new{root=prefixes,total=prefixes.Count});
context.Response.Flush();
context.Response.End();
}
公共布尔可重用{get{return false;}}
}

调试时,我会检查这个.isLoading(),看看它是否仍在尝试加载奇人。最好将所有内容移动到datachanged事件。如果需要分析存储,请使用console.dir(Ext.apply({},this));在运行时获取快照。

如果减慢服务器代码的速度有帮助,则问题在于服务器代码。显示该代码将为您提供更好的答案。我怀疑你的数据库锁定了什么。你们写出了在数据访问过程中发生的任何异常吗?谢谢你们的回答,但我的服务器代码中并没有出现异常,我刚刚检查过。我还用我的服务器代码编辑了我的帖子,以获得更好的帮助服务器响应了什么?您可以在网络选项卡的开发者工具中使用Chrome查看JSON数据,并检查请求。这至少可以帮助您确定Ext向您提供错误时服务器响应是否有故障,或者问题是否在您的客户端的某个地方。