asynchronous call back and session variables.....

O

Ollie

I have an asp.net webservice that is called from an asp.net website, the
processes on the web service may take sometime so I call the webservice
using the asynchronous method calls, i.e. BeginXXXX(), EndXXXX() etc...

I pass a call back into the BeginXXX method so that when the operation has
completed the call back method is called.....

So in the web page it looks something like this:-

private void BeginUpdateData()
{
AsyncCallback AsyncCallBack = new AsyncCallback(UpdateCallback);
System.IAsyncResult asyncResult =
Analyser.BeginUpdateXXXX(serializedData, AsyncCallBack, null);

Session["Processing"] = true;
Session["ProcessingMessage"] = "Updating Entry....";
Session["ProcessingRefreshTime"] = 2;
Session["ProcessingRedirectPath"] = Request.Path;
Response.Redirect(Request.ApplicationPath +
"/Analysis/Processing.aspx", true);
}

public void UpdateCallback(IAsyncResult ar)
{
EndUpdateData(ar);
}

private void EndUpdateData(System.IAsyncResult asyncResult)
{
string data = null;
data = Analyser.EndUpdateXXXX(asyncResult);

Session["Processing"] = null;
}

And the processing.aspx page_load is:

private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Processing"] == null)
{
Session["ProcessingMessage"] = null;
Session["ProcessingRefreshTime"] = null;

string redirectPath =
(string)Session["ProcessingRedirectPath"];
Session["ProcessingRedirectPath"] = null;

Response.Redirect(redirectPath);
}

string message = (string)Session["ProcessingMessage"];
int refreshTime = (int)Session["ProcessingRefreshTime"];

Response.AddHeader("Refresh", refreshTime.ToString());
lbProcessing.Text = message;
}


The problem is that when the asynchronous call back is called it clears the
session variable "Processing", BUT next time the processing.aspx page
refreshes the session variable still exists with the value 'true' to
therefore it does not redirect. I am using out-of-proc session management
using StateServer

Have I made a simple mistake?

Can anyoen help ?

Cheers in Advance

Ollie
 
J

John Saunders

Ollie said:
I have an asp.net webservice that is called from an asp.net website, the
processes on the web service may take sometime so I call the webservice
using the asynchronous method calls, i.e. BeginXXXX(), EndXXXX() etc...

I pass a call back into the BeginXXX method so that when the operation has
completed the call back method is called.....

So in the web page it looks something like this:-

private void BeginUpdateData()
{
AsyncCallback AsyncCallBack = new AsyncCallback(UpdateCallback);
System.IAsyncResult asyncResult =
Analyser.BeginUpdateXXXX(serializedData, AsyncCallBack, null);

Session["Processing"] = true;
Session["ProcessingMessage"] = "Updating Entry....";
Session["ProcessingRefreshTime"] = 2;
Session["ProcessingRedirectPath"] = Request.Path;
Response.Redirect(Request.ApplicationPath +
"/Analysis/Processing.aspx", true);
}

public void UpdateCallback(IAsyncResult ar)
{
EndUpdateData(ar);
}

private void EndUpdateData(System.IAsyncResult asyncResult)
{
string data = null;
data = Analyser.EndUpdateXXXX(asyncResult);

Session["Processing"] = null;
}

And the processing.aspx page_load is:

private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Processing"] == null)
{
Session["ProcessingMessage"] = null;
Session["ProcessingRefreshTime"] = null;

string redirectPath =
(string)Session["ProcessingRedirectPath"];
Session["ProcessingRedirectPath"] = null;

Response.Redirect(redirectPath);
}

string message = (string)Session["ProcessingMessage"];
int refreshTime = (int)Session["ProcessingRefreshTime"];

Response.AddHeader("Refresh", refreshTime.ToString());
lbProcessing.Text = message;
}


The problem is that when the asynchronous call back is called it clears the
session variable "Processing", BUT next time the processing.aspx page
refreshes the session variable still exists with the value 'true' to
therefore it does not redirect. I am using out-of-proc session management
using StateServer

Have I made a simple mistake?

Yup.

Once a page is rendered to the users browser, the page is destroyed. So,
after your page is destroyed, your UpdateCallback gets called...
 
O

Ollie

so what a aafect does that have....

the UpdateCallback does get called, the problem is session variables are not
being updated correctly.....

John Saunders said:
Ollie said:
I have an asp.net webservice that is called from an asp.net website, the
processes on the web service may take sometime so I call the webservice
using the asynchronous method calls, i.e. BeginXXXX(), EndXXXX() etc...

I pass a call back into the BeginXXX method so that when the operation has
completed the call back method is called.....

So in the web page it looks something like this:-

private void BeginUpdateData()
{
AsyncCallback AsyncCallBack = new AsyncCallback(UpdateCallback);
System.IAsyncResult asyncResult =
Analyser.BeginUpdateXXXX(serializedData, AsyncCallBack, null);

Session["Processing"] = true;
Session["ProcessingMessage"] = "Updating Entry....";
Session["ProcessingRefreshTime"] = 2;
Session["ProcessingRedirectPath"] = Request.Path;
Response.Redirect(Request.ApplicationPath +
"/Analysis/Processing.aspx", true);
}

public void UpdateCallback(IAsyncResult ar)
{
EndUpdateData(ar);
}

private void EndUpdateData(System.IAsyncResult asyncResult)
{
string data = null;
data = Analyser.EndUpdateXXXX(asyncResult);

Session["Processing"] = null;
}

And the processing.aspx page_load is:

private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Processing"] == null)
{
Session["ProcessingMessage"] = null;
Session["ProcessingRefreshTime"] = null;

string redirectPath =
(string)Session["ProcessingRedirectPath"];
Session["ProcessingRedirectPath"] = null;

Response.Redirect(redirectPath);
}

string message = (string)Session["ProcessingMessage"];
int refreshTime = (int)Session["ProcessingRefreshTime"];

Response.AddHeader("Refresh", refreshTime.ToString());
lbProcessing.Text = message;
}


The problem is that when the asynchronous call back is called it clears the
session variable "Processing", BUT next time the processing.aspx page
refreshes the session variable still exists with the value 'true' to
therefore it does not redirect. I am using out-of-proc session management
using StateServer

Have I made a simple mistake?

Yup.

Once a page is rendered to the users browser, the page is destroyed. So,
after your page is destroyed, your UpdateCallback gets called...
 
J

John Saunders

Ollie said:
so what a aafect does that have....

the UpdateCallback does get called, the problem is session variables are not
being updated correctly.....

And I wonder if that might because you're referring to Page.Session, where
the Page has been destroyed...

Does it really make sense to you to call instance methods of instances which
have been Disposed?
--
John Saunders
John.Saunders at SurfControl.com
John Saunders said:
Ollie said:
I have an asp.net webservice that is called from an asp.net website, the
processes on the web service may take sometime so I call the webservice
using the asynchronous method calls, i.e. BeginXXXX(), EndXXXX() etc...

I pass a call back into the BeginXXX method so that when the operation has
completed the call back method is called.....

So in the web page it looks something like this:-

private void BeginUpdateData()
{
AsyncCallback AsyncCallBack = new AsyncCallback(UpdateCallback);
System.IAsyncResult asyncResult =
Analyser.BeginUpdateXXXX(serializedData, AsyncCallBack, null);

Session["Processing"] = true;
Session["ProcessingMessage"] = "Updating Entry....";
Session["ProcessingRefreshTime"] = 2;
Session["ProcessingRedirectPath"] = Request.Path;
Response.Redirect(Request.ApplicationPath +
"/Analysis/Processing.aspx", true);
}

public void UpdateCallback(IAsyncResult ar)
{
EndUpdateData(ar);
}

private void EndUpdateData(System.IAsyncResult asyncResult)
{
string data = null;
data = Analyser.EndUpdateXXXX(asyncResult);

Session["Processing"] = null;
}

And the processing.aspx page_load is:

private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Processing"] == null)
{
Session["ProcessingMessage"] = null;
Session["ProcessingRefreshTime"] = null;

string redirectPath =
(string)Session["ProcessingRedirectPath"];
Session["ProcessingRedirectPath"] = null;

Response.Redirect(redirectPath);
}

string message = (string)Session["ProcessingMessage"];
int refreshTime = (int)Session["ProcessingRefreshTime"];

Response.AddHeader("Refresh", refreshTime.ToString());
lbProcessing.Text = message;
}


The problem is that when the asynchronous call back is called it
clears
the
session variable "Processing", BUT next time the processing.aspx page
refreshes the session variable still exists with the value 'true' to
therefore it does not redirect. I am using out-of-proc session management
using StateServer

Have I made a simple mistake?

Yup.

Once a page is rendered to the users browser, the page is destroyed. So,
after your page is destroyed, your UpdateCallback gets called...
 
O

Ollie

how else are you meant to do asynchronous programming in .Net when the
session state is NOT in-proc....

the class that implements the System.IAsyncResult interface does not support
serialisation so you tell me how is an asynchronous call to a web service is
meant to inform the calling asp.net website that it has finished processing?

If you can't then you are not answering the original question and therefore
are not providing any HELPFUL information.


Ollie

John Saunders said:
Ollie said:
so what a aafect does that have....

the UpdateCallback does get called, the problem is session variables are not
being updated correctly.....

And I wonder if that might because you're referring to Page.Session, where
the Page has been destroyed...

Does it really make sense to you to call instance methods of instances which
have been Disposed?
--
John Saunders
John.Saunders at SurfControl.com
John Saunders said:
"Ollie" <why do they need this!!!!> wrote in message
I have an asp.net webservice that is called from an asp.net website, the
processes on the web service may take sometime so I call the webservice
using the asynchronous method calls, i.e. BeginXXXX(), EndXXXX() etc...

I pass a call back into the BeginXXX method so that when the
operation
has
completed the call back method is called.....

So in the web page it looks something like this:-

private void BeginUpdateData()
{
AsyncCallback AsyncCallBack = new AsyncCallback(UpdateCallback);
System.IAsyncResult asyncResult =
Analyser.BeginUpdateXXXX(serializedData, AsyncCallBack, null);

Session["Processing"] = true;
Session["ProcessingMessage"] = "Updating Entry....";
Session["ProcessingRefreshTime"] = 2;
Session["ProcessingRedirectPath"] = Request.Path;
Response.Redirect(Request.ApplicationPath +
"/Analysis/Processing.aspx", true);
}

public void UpdateCallback(IAsyncResult ar)
{
EndUpdateData(ar);
}

private void EndUpdateData(System.IAsyncResult asyncResult)
{
string data = null;
data = Analyser.EndUpdateXXXX(asyncResult);

Session["Processing"] = null;
}

And the processing.aspx page_load is:

private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Processing"] == null)
{
Session["ProcessingMessage"] = null;
Session["ProcessingRefreshTime"] = null;

string redirectPath =
(string)Session["ProcessingRedirectPath"];
Session["ProcessingRedirectPath"] = null;

Response.Redirect(redirectPath);
}

string message = (string)Session["ProcessingMessage"];
int refreshTime = (int)Session["ProcessingRefreshTime"];

Response.AddHeader("Refresh", refreshTime.ToString());
lbProcessing.Text = message;
}


The problem is that when the asynchronous call back is called it clears
the
session variable "Processing", BUT next time the processing.aspx page
refreshes the session variable still exists with the value 'true' to
therefore it does not redirect. I am using out-of-proc session management
using StateServer

Have I made a simple mistake?

Yup.

Once a page is rendered to the users browser, the page is destroyed. So,
after your page is destroyed, your UpdateCallback gets called...
 
J

John Saunders

Ollie said:
how else are you meant to do asynchronous programming in .Net when the
session state is NOT in-proc....

the class that implements the System.IAsyncResult interface does not support
serialisation so you tell me how is an asynchronous call to a web service is
meant to inform the calling asp.net website that it has finished processing?

If you can't then you are not answering the original question and therefore
are not providing any HELPFUL information.

You may want to look in this newsgroup for a thread titled "How to access
the Session object from a new thread ?". John Smith just had what is
basically the same question, and I believe he got where he was going by the
end of the discussion.
--
John Saunders
John.Saunders at SurfControl.com
John Saunders said:
Ollie said:
so what a aafect does that have....

the UpdateCallback does get called, the problem is session variables
are
not
being updated correctly.....

And I wonder if that might because you're referring to Page.Session, where
the Page has been destroyed...

Does it really make sense to you to call instance methods of instances which
have been Disposed?
--
John Saunders
John.Saunders at SurfControl.com
"John Saunders" <john.saunders at SurfControl.com> wrote in message
"Ollie" <why do they need this!!!!> wrote in message
I have an asp.net webservice that is called from an asp.net
website,
the
processes on the web service may take sometime so I call the webservice
using the asynchronous method calls, i.e. BeginXXXX(), EndXXXX() etc...

I pass a call back into the BeginXXX method so that when the operation
has
completed the call back method is called.....

So in the web page it looks something like this:-

private void BeginUpdateData()
{
AsyncCallback AsyncCallBack = new AsyncCallback(UpdateCallback);
System.IAsyncResult asyncResult =
Analyser.BeginUpdateXXXX(serializedData, AsyncCallBack, null);

Session["Processing"] = true;
Session["ProcessingMessage"] = "Updating Entry....";
Session["ProcessingRefreshTime"] = 2;
Session["ProcessingRedirectPath"] = Request.Path;
Response.Redirect(Request.ApplicationPath +
"/Analysis/Processing.aspx", true);
}

public void UpdateCallback(IAsyncResult ar)
{
EndUpdateData(ar);
}

private void EndUpdateData(System.IAsyncResult asyncResult)
{
string data = null;
data = Analyser.EndUpdateXXXX(asyncResult);

Session["Processing"] = null;
}

And the processing.aspx page_load is:

private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Processing"] == null)
{
Session["ProcessingMessage"] = null;
Session["ProcessingRefreshTime"] = null;

string redirectPath =
(string)Session["ProcessingRedirectPath"];
Session["ProcessingRedirectPath"] = null;

Response.Redirect(redirectPath);
}

string message = (string)Session["ProcessingMessage"];
int refreshTime = (int)Session["ProcessingRefreshTime"];

Response.AddHeader("Refresh", refreshTime.ToString());
lbProcessing.Text = message;
}


The problem is that when the asynchronous call back is called it clears
the
session variable "Processing", BUT next time the processing.aspx page
refreshes the session variable still exists with the value 'true' to
therefore it does not redirect. I am using out-of-proc session
management
using StateServer

Have I made a simple mistake?

Yup.

Once a page is rendered to the users browser, the page is destroyed. So,
after your page is destroyed, your UpdateCallback gets called...
 
B

bruce barker

your callback is completing after the page render (probably after unload) so
Session is no longer valid.

-- bruce (sqlwork.com)



Ollie said:
so what a aafect does that have....

the UpdateCallback does get called, the problem is session variables are not
being updated correctly.....

John Saunders said:
Ollie said:
I have an asp.net webservice that is called from an asp.net website, the
processes on the web service may take sometime so I call the webservice
using the asynchronous method calls, i.e. BeginXXXX(), EndXXXX() etc...

I pass a call back into the BeginXXX method so that when the operation has
completed the call back method is called.....

So in the web page it looks something like this:-

private void BeginUpdateData()
{
AsyncCallback AsyncCallBack = new AsyncCallback(UpdateCallback);
System.IAsyncResult asyncResult =
Analyser.BeginUpdateXXXX(serializedData, AsyncCallBack, null);

Session["Processing"] = true;
Session["ProcessingMessage"] = "Updating Entry....";
Session["ProcessingRefreshTime"] = 2;
Session["ProcessingRedirectPath"] = Request.Path;
Response.Redirect(Request.ApplicationPath +
"/Analysis/Processing.aspx", true);
}

public void UpdateCallback(IAsyncResult ar)
{
EndUpdateData(ar);
}

private void EndUpdateData(System.IAsyncResult asyncResult)
{
string data = null;
data = Analyser.EndUpdateXXXX(asyncResult);

Session["Processing"] = null;
}

And the processing.aspx page_load is:

private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Processing"] == null)
{
Session["ProcessingMessage"] = null;
Session["ProcessingRefreshTime"] = null;

string redirectPath =
(string)Session["ProcessingRedirectPath"];
Session["ProcessingRedirectPath"] = null;

Response.Redirect(redirectPath);
}

string message = (string)Session["ProcessingMessage"];
int refreshTime = (int)Session["ProcessingRefreshTime"];

Response.AddHeader("Refresh", refreshTime.ToString());
lbProcessing.Text = message;
}


The problem is that when the asynchronous call back is called it
clears
the
session variable "Processing", BUT next time the processing.aspx page
refreshes the session variable still exists with the value 'true' to
therefore it does not redirect. I am using out-of-proc session management
using StateServer

Have I made a simple mistake?

Yup.

Once a page is rendered to the users browser, the page is destroyed. So,
after your page is destroyed, your UpdateCallback gets called...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top