473,547 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
+ 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.Cur rent.Response.R edirect("file.t xt") 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_Sta rt(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub CreateTimer()
Dim myTimer As New System.Timers.T imer()
myTimer.Interva l = 3000
myTimer.Enabled = True

AddHandler myTimer.Elapsed , New
System.Timers.E lapsedEventHand ler(AddressOf Me.myTimer_Elap sed)
End Sub

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

HttpContext.Cur rent.Response.R edirect("prova. txt")
End Sub

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

End Sub

Sub Application_Err or(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub Session_Start(B yVal sender As Object, ByVal e As EventArgs)
CreateTimer()

End Sub

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

</script>

Nov 19 '05 #1
5 6947
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*******@yaho o.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...
I've read a previous discussion about the same topic, but there's a
difference.
I call HttpContext.Cur rent.Response.R edirect("file.t xt") 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_Sta rt(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub CreateTimer()
Dim myTimer As New System.Timers.T imer()
myTimer.Interva l = 3000
myTimer.Enabled = True

AddHandler myTimer.Elapsed , New
System.Timers.E lapsedEventHand ler(AddressOf Me.myTimer_Elap sed)
End Sub

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

HttpContext.Cur rent.Response.R edirect("prova. txt")
End Sub

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

End Sub

Sub Application_Err or(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub Session_Start(B yVal sender As Object, ByVal e As EventArgs)
CreateTimer()

End Sub

Sub Session_End(ByV al 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*******@yaho o.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...
I've read a previous discussion about the same topic, but there's a
difference.
I call HttpContext.Cur rent.Response.R edirect("file.t xt") 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_Sta rt(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub CreateTimer()
Dim myTimer As New System.Timers.T imer()
myTimer.Interva l = 3000
myTimer.Enabled = True

AddHandler myTimer.Elapsed , New
System.Timers.E lapsedEventHand ler(AddressOf Me.myTimer_Elap sed)
End Sub

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

HttpContext.Cur rent.Response.R edirect("prova. txt")
End Sub

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

End Sub

Sub Application_Err or(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub Session_Start(B yVal sender As Object, ByVal e As EventArgs)
CreateTimer()

End Sub

Sub Session_End(ByV al 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*******@yaho o.com> a écrit dans le message de
news:11******** *************@g 43g2000cwa.goog legroups.com...
I've read a previous discussion about the same topic, but there's a
difference.
I call HttpContext.Cur rent.Response.R edirect("file.t xt") 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_Sta rt(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub CreateTimer()
Dim myTimer As New System.Timers.T imer()
myTimer.Interva l = 3000
myTimer.Enabled = True

AddHandler myTimer.Elapsed , New
System.Timers.E lapsedEventHand ler(AddressOf Me.myTimer_Elap sed)
End Sub

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

HttpContext.Cur rent.Response.R edirect("prova. txt")
End Sub

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

End Sub

Sub Application_Err or(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Sub Session_Start(B yVal sender As Object, ByVal e As EventArgs)
CreateTimer()

End Sub

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

</script>

Nov 19 '05 #4
"Piz" <tw*******@yaho o.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.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 log as well as fire up my email class and generate an email to send me the error. But no matter what I do, I still get the icky looking yellow and...
5
1469
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 page - <customErrors mode="on" defaultRedirect="Error.aspx"/> But how do I reference the exception that occurred from that page? If I cant, then...
7
2337
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 files. The errorpage.aspx uses Server.GetLastError() and shows a friendly error page. But when it happens in global.asax itself, the...
6
2359
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 like: throw new Exception("This a Error Test !!"); It will not redirect to GenericErrorPage.aspx, but if I throw the same Exception in other web...
19
10166
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 app using web application projects and it's firing fine but it was upgraded from the 1.1 framework. Why doesn't my global.asax application_error...
1
1899
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 page load. Everything seems to work OK except catch the actual error. It detects the error when I break the connection string to MS SQL or pause the...
3
3455
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 picking up the string from session an Error.aspx. 1 Dim errorString As String = "the whole error string" 2 Try
0
1944
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 HttpCookie = HttpContext.Current.Request.Cookies("MyCookieName") ' Handle if cookie not exist If cookie Is Nothing Then ...
0
1454
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 under .asp extensions. Web Service Extensions has: Active Server Pages, ASP 1, 2, and 4 "allowed" Thanks in advance global.asax: void...
0
7510
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7437
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7463
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7797
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5362
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3493
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1923
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 we have to send another system
1
1050
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.