Application_End called everytimg I do a file IO

  • Thread starter Thread starter Rykie
  • Start date Start date
R

Rykie

Hi,

I am hoping someone can shed some light on my problem here.

I have a .net2 web app, and the app has a logfile that sits under the
App_GlobalResources folder. The file is called log.txt. I use this file
to write events to, such as errors etc. My problem is that everytime I
write to it, it calls the Application_End evnt in Global.asax file. So
all my sessions and classes have to be re-initialised.

Here is the code I use to write to the file.

Try
If IsLoggedIn.Equals(False) Then
Server.Transfer("login.aspx", False)
Exit Sub
End If

Dim _fi As New
FileInfo(Server.MapPath("App_GlobalResources") & "\log.txt")
If _fi.Exists Then
_fi.Delete()
Dim _sw As StreamWriter = _fi.CreateText
_sw.WriteLine("")
_sw.Flush()
_sw.Close()
End If

Catch tae As Threading.ThreadAbortException

Catch ex As Exception
Response.Write(ex.ToString)
End Try

Thanks,
Rykie
 
Ok, got a fix for the problem, but I am not sure why. The fix is to use
another folder such as App_Data or any other user created folder for
the job.

It seems that when you try to write to a file in the
App_GlobalResources folder, it causes the application to crash, BUT
without throwing any errors.

Thanks,
Rykie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top