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> 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>
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>
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>
"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
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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |