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:
vb.net Code:
  1. Public Class Global_asax
  2.     Inherits System.Web.HttpApplication
  3.  
  4.     Dim path As String
  5.     Dim timer As System.Threading.Timer
  6.  
  7.     Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
  8.         ' Fires when the application is started
  9.  
  10.         path = Server.MapPath("~/Images/top5.jpg")
  11.         timer = New System.Threading.Timer(AddressOf TimerTick)
  12.         timer.Change(1000, 300000)
  13.     End Sub
  14.  
  15.     Sub TimerTick(ByVal status As Object)
  16.         Try
  17.             Top5Image.UpdateTop5(path)
  18.         Catch ex As Exception
  19.             Debug.WriteLine(ex)
  20.         End Try
  21.     End Sub
  22.  
  23. End Class
The Top5Image.UpdateTop5 method will create and save the image.


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!