473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Missing Web log Entry's for file downloads

Hi,

I have been using the code (some of it has been removed for simplicity)
below to allow authenticated (using ASP.NET membership database) users to get
a file from their archive area. It seems to work fine, however I noticed
that no web log entry is added when a successful download occurs (normally a
200 HTTP status code, however, if there is an authorization failure, it gets
logged). I have a logging routine that logs a successful download to a
database, but the W3SVC IIS log has nothing. The code below is contained in
an .ashx file. One other thing to note, I have added MADAM to the web
application, to allow for basic authentication (they might use WGET to
download archives, instead of the web forms).

Thanks.

Public Class GetArchive : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest
Dim strFileName As String = String.Empty
Dim blnTransmittingFile As Boolean = False
Try
context.Response.Buffer = True
If context.User.Identity.IsAuthenticated = True Then
strFileName = context.Request.QueryString("file")
If String.IsNullOrEmpty(strFileName) = False Then
strFileName = System.IO.Path.GetFileName(strFileName)
context.Response.Clear()

Dim objFileInfo As New System.IO.FileInfo(strFileName)
Dim intFileSize As Long = 0

If objFileInfo IsNot Nothing Then
intFileSize = objFileInfo.Length
End If

context.Response.StatusCode = 200
context.Response.ContentType = "application/zip"
context.Response.AddHeader("Content-Disposition",
"attachment; filename=" + strFileName)
context.Response.AddHeader("Content-Length",
intFileSize.ToString())

If context.Request.HttpMethod <"HEAD" Then
Dim dtStart As DateTime = Now()
Dim dtFinish As DateTime
Dim tsTimeTaken As TimeSpan
context.Response.SuppressContent = False
context.Response.Buffer = False
context.Response.BufferOutput = False
blnTransmittingFile = True
context.Response.TransmitFile(strFileName, 0, -1)
context.Response.Flush()
context.Response.Close()
dtFinish = Now()
tsTimeTaken = dtFinish - dtStart
EventLogger.LogDownloadEvent(strFileName,
strUserName, tsTimeTaken.TotalSeconds)
End If
Else
context.Response.Clear()
context.Response.ContentType = "text/plain"
context.Response.StatusCode = 404
context.Response.Write("File Not Found")
End If
End If

Catch ex As Exception
If blnTransmittingFile = False Then
context.Response.Clear()
context.Response.ClearContent()
context.Response.ClearHeaders()
context.Response.ContentType = "text/plain"
End If
context.Response.StatusCode = 403
context.Response.Write("Request failed [" + ex.ToString() + "]")
EventLogger.LogDownloadEvent("Failed", ex.ToString())
End Try
End Sub

Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
Jul 24 '08 #1
0 1090

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
0
by: kris | last post by:
hi can any one help me out, i have written a code for Word Indexing using Dll's i think this is an incomplete code for WORD INDEX. I had encountered this error "Error! No index entries found"...
2
by: danceli | last post by:
I have made trigger on table 'FER' that would be fired if data is inserted, updated to the table. And also, I made batch file using bcp to extract the newly updated / inserted records. But I got...
1
by: Byomokesh | last post by:
Hi All, This XML file is 2 errors. My table is 3 columns. One is extra column and another is missing one columne. How i will find those error through perl script. XML file ------------ ...
6
by: Miro | last post by:
I can run an exe ( and its install ) i have created on my machine. The exe has a button that populates a dataset and then shoots it to a crystal report. But... Installing the setup.exe on my...
4
by: Miro | last post by:
<i have also added this reply to the other newsgroup - now that I have realizd ( and assuming ) it is not a localized error directly to vb.> I have found this link on the website:...
1
by: mrpetegroups | last post by:
Hi - Problem: The file below has become zero length \winnt\assembly\GAC_MSIL\system.deployment\2.0.0.0_b03f5f7f11d50a3a \system.deployment.dll Details follow ... I've been programming...
7
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.