【问题标题】:jQuery too slow with Asp.Net Development ServerjQuery 在 Asp.Net 开发服务器上太慢了
【发布时间】:2009-09-14 19:20:31
【问题描述】:

我打算用 ASP.NET 3.5 运行 jQuery 和 AJAX。在 Visual Studio 开发服务器 (Cassini) 上,对 .aspx 页面的调用太慢。大约需要 30 秒。然后,如果我调试它会在断点处停止,它也会返回带有日期的 JSON。但是,发布到 IIS 网站的相同代码运行良好且运行速度快。

环境:(Windows Vista 64 + Visual Studio 2008)

ASPX 页面

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Calling a page method with jQuery</title>
<script type="text/javascript" src="Scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="Scripts/Default.js"></script>
</head>
<body>
<div id="Result">Click here for the time.</div>
</body>
</html>

文件 - Scripts/Default.js

$(document).ready(function() {
// Add the page method call as an onclick handler for the div.
$("#Result").click(function() {
    $.ajax({
        type: "POST",
        url: "Default.aspx/GetDate",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            // Replace the div's content with the page method's return.
            $("#Result").text(msg.d);
        }
    });
});
});

文件 - Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class _Default : System.Web.UI.Page 

{

    [WebMethod]
    public static string GetDate()
    {
        return DateTime.Now.ToString();
    }
}

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    如果您第一次编译并运行应用程序,这是正常的。 IIS 必须编译应用程序并将其放入缓存中。这只发生在第一次。如果您在没有调试的情况下访问同一页面,则不会花费那么长时间。在第一次之后,对同一页面的所有其他请求都应该很快。

    你应该和Precompilation of ASP.NET联系

    检查缓存中是否有符号

    Slow loading in debug

    【讨论】:

    • 不,在 iis 中,第一次和下一次调用太快(1 秒),但在开发服务器中每次大约(30 秒)并且没有调试(IE,Firefox 3)。而在 Firefox 3 中的 iss 发布站点运行不起作用...(但在 IE 8 中是的。
    猜你喜欢
    • 2012-10-08
    • 2015-11-12
    • 1970-01-01
    • 2010-10-15
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    • 2021-11-18
    • 1970-01-01
    相关资源
    最近更新 更多