使用Asp.Net开发服务器时,jQuery速度太慢
我打算用ASP.NET3.5运行jQuery和AJAX。在VisualStudioDevelopmentServer(Cassini)上,对.aspx页面的调用太慢。大约需要30秒。然后,如果我调试,它将在断点处停止,并返回带有日期的JSON。但是,发布到IIS网站的相同代码运行良好,运行速度也很快 环境:(Windows Vista 64+Visual Studio 2008) ASPX页面使用Asp.Net开发服务器时,jQuery速度太慢,asp.net,Asp.net,我打算用ASP.NET3.5运行jQuery和AJAX。在VisualStudioDevelopmentServer(Cassini)上,对.aspx页面的调用太慢。大约需要30秒。然后,如果我调试,它将在断点处停止,并返回带有日期的JSON。但是,发布到IIS网站的相同代码运行良好,运行速度也很快 环境:(Windows Vista 64+Visual Studio 2008) ASPX页面 <html xmlns="http://www.w3.org/1999/xhtml"> &
<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>
文件-Default.aspx.cs
$(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);
}
});
});
});
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();
}
}
第一次编译并运行应用程序是正常的。IIS必须编译应用程序并将其放入is缓存中。这只是第一次发生。如果您在没有调试的情况下访问同一页,那么不会花那么长时间。在第一次之后,对同一页面的每一个其他请求都应该是快速的 你应该和我核对一下 检查缓存中是否有符号
否,在iis中,第一次和下一次调用速度太快(1秒),但在Development Server中,每次调用速度约为(30秒),且未进行调试(即Firefox 3)。在Firefox3中的iss发布站点运行不起作用…(但在IE8中是的。