2

我有一个奇怪的问题,它并不总是出现,但有时会出现相同的请求。在我的网站(本地主机)上,我有一个带有自动加载功能的 ExtJS 存储,在页面加载(按下 F5 按钮)之后,它从服务器的某个处理程序(* .ashx)中读取 JSON。处理程序从数据库中获取数据并将其序列化为 JSON。按 F5 可工作 4 次 5。第 5 次 json-reader 显示 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; } }
}
4

1 回答 1

0

调试时,我会检查 this.isLoading() 以查看它是否仍在尝试加载奇怪的人。将所有内容移至 datachanged 事件可能会更好。如果需要分析store,使用console.dir(Ext.apply({}, this)); 在运行时获取快照。

于 2013-04-27T02:32:28.100 回答