473,698 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

First PageMethod blocks second page method from executing

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="tes tnomaster.aspx. cs" Inherits="Galle ryServerPro.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.Web Method1(WebMeth od1Completed, WebMethod1Faile d);

PageMethods.Web Method2(WebMeth od2Completed, WebMethod2Faile d);
}

function WebMethod1Compl eted(results, context, methodName)
{

}

function WebMethod1Faile d(results, context, methodName)
{
alert("failed") ;
}

function WebMethod2Compl eted(results, context, methodName)
{

}

function WebMethod2Faile d(results, context, methodName)
{
alert("failed") ;
}

</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptMana ger ID="ScriptManag er1" runat="server"
EnablePageMetho ds="true">
</asp:ScriptManag er>
<input type="button" onclick="startT ask()" value="Start" />
</form>
</body>
</html>

Code behind:

using System;
using System.Web.UI;

namespace GalleryServerPr o.Web
{
public partial class test : Page
{
protected void Page_Load(objec t sender, EventArgs e)
{
}

[System.Web.Serv ices.WebMethod]
public static void WebMethod1()
{
System.Threadin g.Thread.Sleep( 10000);
}

[System.Web.Serv ices.WebMethod]
public static void WebMethod2()
{
System.Threadin g.Thread.Sleep( 10000);
}

}
}

Jul 23 '07 #1
2 1992
if you use sesson, then session locking prevents two concurrent
requests. turn off session in one of the requests.

-- bruce (sqlwork.com)

Roger Martin wrote:
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="tes tnomaster.aspx. cs" Inherits="Galle ryServerPro.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.Web Method1(WebMeth od1Completed, WebMethod1Faile d);

PageMethods.Web Method2(WebMeth od2Completed, WebMethod2Faile d);
}

function WebMethod1Compl eted(results, context, methodName)
{

}

function WebMethod1Faile d(results, context, methodName)
{
alert("failed") ;
}

function WebMethod2Compl eted(results, context, methodName)
{

}

function WebMethod2Faile d(results, context, methodName)
{
alert("failed") ;
}

</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptMana ger ID="ScriptManag er1" runat="server"
EnablePageMetho ds="true">
</asp:ScriptManag er>
<input type="button" onclick="startT ask()" value="Start" />
</form>
</body>
</html>

Code behind:

using System;
using System.Web.UI;

namespace GalleryServerPr o.Web
{
public partial class test : Page
{
protected void Page_Load(objec t sender, EventArgs e)
{
}

[System.Web.Serv ices.WebMethod]
public static void WebMethod1()
{
System.Threadin g.Thread.Sleep( 10000);
}

[System.Web.Serv ices.WebMethod]
public static void WebMethod2()
{
System.Threadin g.Thread.Sleep( 10000);
}

}
}
Jul 23 '07 #2
You are right that session was causing the problem. Thanks!

But how can I turn off session for one of the requests? I know I can set
EnableSessionSt ate="false" for the page directive, but the web page *does*
use session, so this won't work. However, neither of my page methods need
session, so I am happy to turn off session for those. Is this possible, or
can I only disable session at the page level?
Jul 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2051
by: Bengt Richter | last post by:
Useless example first: def foo(x): a = suite: y = 1 b = suite: y = 2 a() # equivalent effect to local y = 1 above (a,b)() # effect of suite b if bool(x), otherwise suite a vars()() # succeeds if x in
3
3456
by: danc | last post by:
I have a datagrid with a checkbox and dropdown list in each row. Both set AutoPostBack to true and ItemCommand and OnSelectedIndexChanged events for these controls works fine when DataGrid is not paged. As soon as I turn on paging support, I no longer get events properly for any page except the first. 1) The DataGrid displays the page numbers on the top (and bottom). Whenever I click to go to a specific page number, the DropDownList's...
3
5687
by: dnadeveloper | last post by:
Can anyone tell me what is is required to get the PageMethod code into my ..aspx pages? (More accurately, into the rendered page.) So far I have a scripmanager with EnablePageMethods wet to true. TIA Chris
3
3277
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
In an earlier thread (http://tinyurl.com/33horg) I learned that when session is enabled on a web page, a second page method is blocked until the first one is complete. Is there any way around this limitation, besides disabling session at the page level? Defining a method like the following doesn't solve the problem because session is already disabled by default for a page method:
3
1441
by: GaryDean | last post by:
I have just been through the docs on the Data Access Application blocks and it seems that they complicate things more than make things simple. To me it seems that there is nothing more simple and straight forward than writing simple stored procedures and executing them from .net code using easy to understand connection strings. I'm looking for opinions here from those that have used these tools. Am I missing something? --
2
5565
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi John, Hopefully this post will find its way back to you - or perhaps be answered by someone else. As I mentioned in my last post on the earlier portion of this thread, changing the serialization settings for the build handled the initial slows we encountered when invoking the web service. Since that time, we ported the original VB.net code over to C# - this was done to make it cleaner easier to include the project in the rest of...
4
1370
by: =?Utf-8?B?RGVubmlz?= | last post by:
Is there any way to find out what is causing a "First Chance Exception"? Also, is there anyway to turn them off....I'm getting hundreds but all seems to run OK. I"m using VB 2008 Express Edition. -- Dennis in Houston
8
2503
by: Rory Becker | last post by:
Hi All I have a need for an asp.net page to make a call to a server which it did not originate from when a button is clicked. A simple call to pass 2-3 params and return a result. I am happy to use an asynchronous model to do this. I control both servers. I have been looking at Ajax and PageMethods (Ajax.Net and Ajax Pro) and have even been looking at Calling a webservice from JS.
0
1562
Frinavale
by: Frinavale | last post by:
I have a peculiar problem... Background: I have a function that I don't want the user to execute more than once while they are waiting for it to process; therefore, I disable all of the controls on the page via some JavaScript before the request is sent. This function takes some time to execute because it has to communicate with hardware that is rather slow. This slowness combined with a little bit of lag sometimes results in a ...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.