newbie quest about System.Timers.Timer

D

Dave Hagerich

I have an ASP.Net v1.1 page with C# code-behind, that after a period of time
I want the page to transfer the user to another page on the server. So I
create and setup a timer and pass to it a delegate to be used for the
elapsed event. This all works fine and after the interval is up the elapsed
function fires. But when it gets to the Server.Transfer() call the following
exception is thrown:

Error executing child request for Login.aspx.
at System.Web.HttpServerUtility.ExecuteInternal(String path, TextWriter
writer, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path)

I'm assuming this is because System.Timers.Timer is asynchronous and the
elapsed method is called on a different thread then the main page. If this
was a windows program I could easily use the Form.Invoke() method to return
control to the main thread, is there a way to accomplish this in ASP.Net?

Thanks in advance

--
Dave Hagerich
(e-mail address removed)

Arc Light Entertainment, Inc.
4637 Benson Avenue
Baltimore, MD 21227

www.arclighte.com
410-536-0292 Voice
410-536-0294 Fax
 
S

S. Justin Gengo

Dave,

You can't do this the way you are trying. The reason you are getting an
error is because the client machine and the server operate asynchronously.
Once the client receives the code for a page request back from the server
the link is broken until the client makes another request.

The timer code is running on the server and firing, but it affects the
server only. The server has no way to contact the client and tell it to move
to another page. To do what you're attempting you'll need to use a meta
transfer tag in the html of the page sent to the client or use a javascript.
Both of those will run on the client machine and cause the behaviour you're
seeking.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
D

Dave Hagerich

Sweet that worked, thanks for the help.

Dave

S. Justin Gengo said:
Dave,

You can't do this the way you are trying. The reason you are getting an
error is because the client machine and the server operate asynchronously.
Once the client receives the code for a page request back from the server
the link is broken until the client makes another request.

The timer code is running on the server and firing, but it affects the
server only. The server has no way to contact the client and tell it to move
to another page. To do what you're attempting you'll need to use a meta
transfer tag in the html of the page sent to the client or use a javascript.
Both of those will run on the client machine and cause the behaviour you're
seeking.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top