Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Server.Transfer doesn't work in a timer callback

Reply
Thread Tools

Server.Transfer doesn't work in a timer callback

 
 
Jim Hammond
Guest
Posts: n/a
 
      10-21-2003
The code below works except that calling Server.Transfer generates the
following exception, and I don't know why yet:

"Error executing child request for Form_Welcome.aspx."

Although a page has a short lifespan, I have discovered that the timer
callback is in fact being called after 10 seconds.

Notet hat "p" appears to be perfectly valid and returns equal when compared
to the original Web Form object, which I saved using Application.Add
specifically to test for such equality.


private void Page_Load(object sender, System.EventArgs e)
{
// Set timer to call Page_PostLoad in 10 seconds
timerDelegate = new TimerCallback(Page_PostLoad);
timer = new Timer( timerDelegate, this, 10000, 0 );
}

static void Page_PostLoad(Object page)
{
Form_ProceedToDesk p = (Form_ProceedToDesk)page;
try
{
// stop timer
p.timer.Dispose();
p.timer = null;
p.GoHome();
}
catch(Exception ex)
{
p.ExceptionDisplay( ex );
}
}

public void GoHome( )
{
Server.Transfer("Form_Welcome.aspx");
}



 
Reply With Quote
 
 
 
 
Colin Young
Guest
Posts: n/a
 
      10-21-2003
It looks to me like you are trying to redirect the user to a new page after
10 seconds. You need to use client-side code to do that, not server-side
code. I think if you search for "meta refresh" you should find an example of
how to do it.

Colin

"Jim Hammond" <(E-Mail Removed)> wrote in message
news:%23rajvx%(E-Mail Removed)...
> The code below works except that calling Server.Transfer generates the
> following exception, and I don't know why yet:
>
> "Error executing child request for Form_Welcome.aspx."
>
> Although a page has a short lifespan, I have discovered that the timer
> callback is in fact being called after 10 seconds.
>
> Notet hat "p" appears to be perfectly valid and returns equal when

compared
> to the original Web Form object, which I saved using Application.Add
> specifically to test for such equality.
>
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Set timer to call Page_PostLoad in 10 seconds
> timerDelegate = new TimerCallback(Page_PostLoad);
> timer = new Timer( timerDelegate, this, 10000, 0 );
> }
>
> static void Page_PostLoad(Object page)
> {
> Form_ProceedToDesk p = (Form_ProceedToDesk)page;
> try
> {
> // stop timer
> p.timer.Dispose();
> p.timer = null;
> p.GoHome();
> }
> catch(Exception ex)
> {
> p.ExceptionDisplay( ex );
> }
> }
>
> public void GoHome( )
> {
> Server.Transfer("Form_Welcome.aspx");
> }
>
>
>



 
Reply With Quote
 
 
 
 
Jim Hammond
Guest
Posts: n/a
 
      10-24-2003
"Colin Young" <(E-Mail Removed)> wrote in message
news:%23$(E-Mail Removed)...
It looks to me like you are trying to redirect the user to a new page after
10 seconds. You need to use client-side code to do that, not server-side
code. I think if you search for "meta refresh" you should find an example of
how to do it.

Colin


Thanks,

That seems to work fine, but I now have three concerns because I thought it
was supposed to be possible to do everything in C#.
1. I manually edited the .aspx file, which means that my code is not as
clean and is harder to maintain.
2. Will server-side code know how to handle the redirection caused by the
META tag as well as if I had used C#?
3. Note that Visual Studio lets the developer drag and drop a timer onto the
web form, which now seems like a pointless feature.

Jim


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Callback high-res timer C++ class Dmitri Sologoubenko C++ 4 09-07-2006 08:35 AM
Callback For A Timer Event To Display Widget in Ruby/Tk David Bailey Ruby 5 03-28-2006 06:37 PM
page timer, or redirect timer Simon ASP .Net 1 11-04-2005 07:14 PM
System.Timers.Timer/System.Threading.Timer Not Firing At All on Dev Server james.e.coleman@gmail.com ASP .Net 1 02-22-2005 09:41 PM
System.Timers.Timer vs. System.Threading.Timer Kelsang Wangchuk ASP .Net 0 07-31-2003 04:28 PM



Advertisments