G
Guest
I am executing an AJAX page method that is a long running task. After
starting the first method, I execute a second page method to retrieve the
status of the task. It works fine in an empty web application, but when I
paste the code into my main application (~10 projects, maybe 100 files) the
behavior changes. What happens is the second page method will not begin
executing until the first one finishes. In other words, the page methods
execute serially.
For the life of me I cannot figure out the difference between my main app
and the empty app where it works. Nothing is different in web.config. What
could possibly be going on in my main app that might cause this behavior?
FYI, I am ultimately trying to implement Dino Esposito's article "Canceling
Server Tasks with ASP.NET AJAX" in the July 2007 MSDN issue. His sample code
behaves the same way as my code below (works fine in empty app but runs
serially in my main app).
ASPX page:
<%@ Page Language="C#" AutoEventWireup="true"
Codebehind="testnomaster.aspx.cs" Inherits="GalleryServerPro.Web.test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function startTask()
{
PageMethods.WebMethod1(WebMethod1Completed, WebMethod1Failed);
PageMethods.WebMethod2(WebMethod2Completed, WebMethod2Failed);
}
function WebMethod1Completed(results, context, methodName)
{
}
function WebMethod1Failed(results, context, methodName)
{
alert("failed");
}
function WebMethod2Completed(results, context, methodName)
{
}
function WebMethod2Failed(results, context, methodName)
{
alert("failed");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true">
</asp:ScriptManager>
<input type="button" onclick="startTask()" value="Start" />
</form>
</body>
</html>
Code behind:
using System;
using System.Web.UI;
namespace GalleryServerPro.Web
{
public partial class test : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Services.WebMethod]
public static void WebMethod1()
{
System.Threading.Thread.Sleep(10000);
}
[System.Web.Services.WebMethod]
public static void WebMethod2()
{
System.Threading.Thread.Sleep(10000);
}
}
}
starting the first method, I execute a second page method to retrieve the
status of the task. It works fine in an empty web application, but when I
paste the code into my main application (~10 projects, maybe 100 files) the
behavior changes. What happens is the second page method will not begin
executing until the first one finishes. In other words, the page methods
execute serially.
For the life of me I cannot figure out the difference between my main app
and the empty app where it works. Nothing is different in web.config. What
could possibly be going on in my main app that might cause this behavior?
FYI, I am ultimately trying to implement Dino Esposito's article "Canceling
Server Tasks with ASP.NET AJAX" in the July 2007 MSDN issue. His sample code
behaves the same way as my code below (works fine in empty app but runs
serially in my main app).
ASPX page:
<%@ Page Language="C#" AutoEventWireup="true"
Codebehind="testnomaster.aspx.cs" Inherits="GalleryServerPro.Web.test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function startTask()
{
PageMethods.WebMethod1(WebMethod1Completed, WebMethod1Failed);
PageMethods.WebMethod2(WebMethod2Completed, WebMethod2Failed);
}
function WebMethod1Completed(results, context, methodName)
{
}
function WebMethod1Failed(results, context, methodName)
{
alert("failed");
}
function WebMethod2Completed(results, context, methodName)
{
}
function WebMethod2Failed(results, context, methodName)
{
alert("failed");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true">
</asp:ScriptManager>
<input type="button" onclick="startTask()" value="Start" />
</form>
</body>
</html>
Code behind:
using System;
using System.Web.UI;
namespace GalleryServerPro.Web
{
public partial class test : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Services.WebMethod]
public static void WebMethod1()
{
System.Threading.Thread.Sleep(10000);
}
[System.Web.Services.WebMethod]
public static void WebMethod2()
{
System.Threading.Thread.Sleep(10000);
}
}
}