473,480 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

redirect from global.asax

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>

Nov 19 '05 #1
5 6934
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.

"Piz" <tw*******@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
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>

Nov 19 '05 #2
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)
"Piz" <tw*******@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
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>

Nov 19 '05 #3
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...)
--

"Piz" <tw*******@yahoo.com> a écrit dans le message de
news:11*********************@g43g2000cwa.googlegro ups.com...
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>

Nov 19 '05 #4
"Piz" <tw*******@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
That doesn't works, i'm quite new in asp.net and so i don't know what a
studip mistake i'm doing!!


ASP.NET and timers really don't go well together. See the following for lots
of articles and discussions around this...

http://www.google.com/search?sourcei...2ENET%22+Timer
Nov 19 '05 #5
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?

Nov 19 '05 #6

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

Similar topics

3
661
by: JP | last post by:
I need to be able to trap errors at the application level. I added this code to the Global.asax file. The code I wrote is supposed to get the last error that was generated and write to the event...
5
1461
by: vbMental | last post by:
I am deep into a project and cannot get this to work correctly. I am trying to make a custom error page that will be able to know what exception occurred. I already know about the defaultRedirect...
7
2335
by: Jonas | last post by:
Hi! I have an Application_Error method in global.asax that uses Server.Transfer to move execution to a custom error page. This works fine when an exception is thrown in one of the aspx or ascx...
6
2352
by: ad | last post by:
I have set customErrors to On and set a defaultRedirect in Web.config like: <customErrors mode="On" defaultRedirect="~/ErrorPage/GenericErrorPage.aspx"> When I throw a exception in Global.asax...
19
10147
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
1
1896
by: Groove | last post by:
Hey guys - I'm sure this is a commonly asked question but here goes. I'm trying to catch the error in my global.asax file and redirect to a error page which will email me the actual error upon...
3
3453
by: kurt sune | last post by:
I have a generic errorhandler in global.asax. (in Application_Error) I need to transfer an error string from global asax to a generic error page. So I try: this code with the thought of...
0
1929
by: daonho | last post by:
Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Dim strPath As String = HttpContext.Current.Request.Path() Dim cookie As...
0
1453
by: user65 | last post by:
Is it possible to convert the following redirects previously in global.asax and global.asa to the web.config file? My server crashed and most of the website works except for the old articles created...
0
7054
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7057
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7003
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...
1
4798
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...
0
3008
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3000
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1310
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
570
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
199
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...

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.