redirect from global.asax

P

Piz

I've read a previous discussion about the same topic, but there's a
difference.
I call HttpContext.Current.Response.Redirect("file.txt") from a ownmade
sub in the global.asax.
That doesn't works, i'm quite new in asp.net and so i don't know what a
studip mistake i'm doing!!

here there's global asax code:
<%@ Application Language="VB" %>

<script runat="server">

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub CreateTimer()
Dim myTimer As New System.Timers.Timer()
myTimer.Interval = 3000
myTimer.Enabled = True

AddHandler myTimer.Elapsed, New
System.Timers.ElapsedEventHandler(AddressOf Me.myTimer_Elapsed)
End Sub

Sub myTimer_Elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs)

HttpContext.Current.Response.Redirect("prova.txt")
End Sub

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)


CreateTimer()

End Sub

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
End Sub

</script>
 
K

Kevin Spencer

HTTP is all about Request and Response. A client makes a Request for a
resource, and the server responds with a Response. Without a Request, there
can be no Response.

An ASP.Net Page is a handler for a Request. A Timer_Elapsed event is not.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
B

Bruce Barker

in general you ca not use a timer in asp.net (unless yuu add code to stall
page processing until the timer fires). in your case the timer has fired
after the page has been delivered to the browser. there is no one to see
the redirect command (which is just an html header).

-- bruce (sqlwork.com)
 
P

Patrice

Explain rather what you are trying to do ? Someone will hopefully suggest
another approach (this one won't work as you'll send a response once the
HTTP request is done, just response.write in beginrequest/endrequest and in
your timer event and you'll better understand the control flow...)
 
P

Piz

i have to refresh a page on the client, but this should be done just
when a table is updated. The problem is that i can't use sql server
2005. This page runs on a palm device, so i can't use the "refresh"
header too, because it doesn't works.
So what can i do?
 

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,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top