473,785 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Pr ocessRequest
Dim strFileName As String = String.Empty
Dim blnTransmitting File As Boolean = False
Try
context.Respons e.Buffer = True
If context.User.Id entity.IsAuthen ticated = True Then
strFileName = context.Request .QueryString("f ile")
If String.IsNullOr Empty(strFileNa me) = False Then
strFileName = System.IO.Path. GetFileName(str FileName)
context.Respons e.Clear()

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

If objFileInfo IsNot Nothing Then
intFileSize = objFileInfo.Len gth
End If

context.Respons e.StatusCode = 200
context.Respons e.ContentType = "applicatio n/zip"
context.Respons e.AddHeader("Co ntent-Disposition",
"attachment ; filename=" + strFileName)
context.Respons e.AddHeader("Co ntent-Length",
intFileSize.ToS tring())

If context.Request .HttpMethod <"HEAD" Then
Dim dtStart As DateTime = Now()
Dim dtFinish As DateTime
Dim tsTimeTaken As TimeSpan
context.Respons e.SuppressConte nt = False
context.Respons e.Buffer = False
context.Respons e.BufferOutput = False
blnTransmitting File = True
context.Respons e.TransmitFile( strFileName, 0, -1)
context.Respons e.Flush()
context.Respons e.Close()
dtFinish = Now()
tsTimeTaken = dtFinish - dtStart
EventLogger.Log DownloadEvent(s trFileName,
strUserName, tsTimeTaken.Tot alSeconds)
End If
Else
context.Respons e.Clear()
context.Respons e.ContentType = "text/plain"
context.Respons e.StatusCode = 404
context.Respons e.Write("File Not Found")
End If
End If

Catch ex As Exception
If blnTransmitting File = False Then
context.Respons e.Clear()
context.Respons e.ClearContent( )
context.Respons e.ClearHeaders( )
context.Respons e.ContentType = "text/plain"
End If
context.Respons e.StatusCode = 403
context.Respons e.Write("Reques t failed [" + ex.ToString() + "]")
EventLogger.Log DownloadEvent(" Failed", ex.ToString())
End Try
End Sub

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

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

Similar topics

5
6128
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 downloads. It uses fpassthru() and some headers() to send a file to the requesting user. The get.php file that I wrote (the file download module if you will) works like a charm for .ZIP files and .TXT files. However, when .EXE files are downloaded...
7
5388
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 from clicking on many of the available topics (mostly methods but some properties are also unavailable). This same problem occurs with many, if not most, keywords. Is there any way I can activate these "missing" help topics? HELP!
0
3096
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" when i opened word document can any one fill out the missing code with this.
2
4275
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 missing data in bcp out file like this: Missing 1200 records, blocked at: /* 777946 296188 2007-01-29 21:25:45.063
1
1491
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 ------------ <table> <tgroup cols="3"> <colspec colnum="1" colname="col1"/> <colspec colnum="2" colname="col2"/>
6
4895
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 other pc, and running it I get an error. The Dataset loads properly, but when the button is pushed to view the report I get this error: ************** Exception Text **************
4
3314
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: https://www.sdn.sap.com/irj/sdn/businessobjects-downloads ..NET Utility CR 2008 Merge Modules for the .NET Framework ZIP 74.716 Windows English 12.03.2008 and it states:
1
2087
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 computers for a long, long time, but VB/.NET/ etc. is not my specialty.
7
2833
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 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...
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.