Hi,
I need to create an image from some data in my database on the server every 5 minutes. The image path is Images/top5.jpg, so that users can place a link to that imagine on some forum or whatever and it will update every 5 minutes.
I am doing this by using a System.Threading.Timer in Global.asax:
The Top5Image.UpdateTop5 method will create and save the image.vb.net Code:
Public Class Global_asax Inherits System.Web.HttpApplication Dim path As String Dim timer As System.Threading.Timer Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Fires when the application is started path = Server.MapPath("~/Images/top5.jpg") timer = New System.Threading.Timer(AddressOf TimerTick) timer.Change(1000, 300000) End Sub Sub TimerTick(ByVal status As Object) Try Top5Image.UpdateTop5(path) Catch ex As Exception Debug.WriteLine(ex) End Try End Sub End Class
Locally, this seems to work OK. The image is created every 5 minutes in the Images folder.
I uploaded the website, but it does not seem to work on the server. What could be causing this?
I thought maybe I don't have write permission on the server or something. What I tried:
- Placed a random image on the server just so one is there already (maybe I could change an image but not create a new one?)
- Gave Write permissions to the Image folder and the image in there.
Doesn't seem to work, it's now just displaying the random image but it should have generated the new image already.
As a side question: how can I debug stuff like this? I am using a Try/Catch block but I'm finding it well... impossible to see any exception. Debug.WriteLine works fine in the IDE but now that it's on the server I've no idea how I could view the error, if any.
Thanks!




Reply With Quote