I'm getting a lot of timeouts on an ashx page which handles file uploads in my web app. Is there a way I could capture the timeout and log some data about the upload to help me better understand what the problem is?
The logger would look something like this, I just need to attach it to a timeout exception!
Private Sub LogTimeoutException(context As HttpContext)
'Gather the data
Dim sb As New StringBuilder()
sb.AppendLine(String.Format("Toal files: {0}", context.Request.Files.Count))
For Each f As HttpPostedFile In context.Request.Files
sb.AppendLine(String.Format("{0} ({1}): {2}", f.FileName, f.ContentType, f.ContentLength))
Next
'Log it
Dim l As New BitFactory.Logging.FileLogger(context.Server.MapPath("~/timeoutlog.txt"))
l.LogInfo(sb.ToString())
End Sub
Any reason why a try catch wouldn't work?
Private Sub LogTimeoutException(context As HttpContext)
Dim sb As New StringBuilder()
Try
//gather the data
sb.AppendLine(String.Format("Toal files: {0}", context.Request.Files.Count))
For Each f As HttpPostedFile In context.Request.Files
sb.AppendLine(String.Format("{0} ({1}): {2}", f.FileName, f.ContentType, f.ContentLength))
Next
Catch he As HttpException
//Log it
Dim l As New BitFactory.Logging.FileLogger(context.Server.MapPath("~/timeoutlog.txt"))
l.LogInfo(sb.ToString())
End Try
End Sub