Response Object - Cache Problem. It's not clearing.

P

PD

I am trying to stream out a PDF file via the response object and when I
execute the code it always brings up the first document that I pulled
up.Even when I step through the code, I can see the new values in
theData string array (see code below), but it serves up the first
document that I had run this code with. I streamed theData into a text
file to look at the values and it contained the appropriate ones for
the new document. Even when I close out of the browser or clear out IE
variables, etc. it still always pulss up the first document. I'm
thinking it could be a cache issue, but everything I have tried in
clearing out the cache has not been successful.

Private Sub CreatePDF()
Dim imgFactory As New CFN.DataServices.Imaging.ImagingFactory
Dim oDataset As DataSet
Dim oPDF As New WebSupergoo.ABCpdf4.Doc
Dim oPDFBytes As WebSupergoo.ABCpdf4.Doc

Dim bytes() As Byte
Dim imgString As String
Dim pageID As Int32
Dim pageCount As Int32 = 1

Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(Now())
Response.ClearHeaders()
Response.ClearContent()

'Response.Expires = -1
'Response.Buffer = True
'Response.Clear()
''Response.Cache.SetNoServerCaching()
''Response.ExpiresAbsolute = New DateTime(2002, 1, 1, 0, 0, 0)
''Response.CacheControl = "Public"
''Response.CacheControl = "no-cache"
''Response.Cache.SetNoStore()

'create temporary license
oPDF.SetInfo(0, "License",
ConfigurationSettings.AppSettings("abcPDFLicenseKey"))
'populate the dataset from session
oDataset = CType(Session("dsSelectedImageList"), DataSet)

For Each oDataRow As DataRow In oDataset.Tables(0).Rows
Dim docID As New
CFN.DataServices.Imaging.DocumentIdentifier
Dim sReportID As String = CType(oDataRow.Item("reportID"),
String)
Dim sReportVersionID As String =
CType(oDataRow.Item("versionID"), String)
Dim sReportSectionID As String =
CType(oDataRow.Item("sectionID"), String)
oPDFBytes = New WebSupergoo.ABCpdf4.Doc

docID.ReportID = sReportID
docID.SectionID = sReportSectionID
docID.VersionID = sReportVersionID

If sReportID = "CONF" Then
oPDFBytes.Read(imgFactory.TradeConfirmOverlay(docID,
Page.User.Identity.Name))
Else
oPDFBytes.Read(imgFactory.GetPDFBytes(docID,
Page.User.Identity.Name))
End If

oPDF.Append(oPDFBytes)
oPDFBytes.Clear()
oPDFBytes = Nothing
Next

Dim theData() As Byte
theData = oPDF.GetData

oPDF.Clear()
oPDF = Nothing

Dim d As Date = Now()

Response.ContentType = "application/pdf"
Response.AddHeader("Pragma", "no-cache")
Response.AddHeader("Expires", "-1")
Response.AddHeader("content-disposition", "inline; filename=" +
Session.SessionID + CType(d.Second, String) + CType(d.Minute, String) +
"ImagePacket.pdf;")
Response.AddHeader("content-length", theData.Length.ToString())

Response.BinaryWrite(theData)
'Response.OutputStream.Write(theData, 0, theData.Length)

'Dim fs As FileStream
'fs = File.Create("c:\temp\test.txt")
'Dim sw As StreamWriter
'sw = New StreamWriter(fs)
'sw.Write(System.Text.Encoding.ASCII.GetString(theData))

'Response.Write(System.Text.Encoding.ASCII.GetString(theData))
Response.Flush()
Response.Close()
Response.End()

End Sub

I have tried setting the cache properities between the HTML HEAD tags
as per suggested with other posts, to no avail. I have tried running
the application from another PC to see if anything would change. I
checked my IE settings to ensure page is being refreshed for every
visit to the page. The application is running on my localhost.

Any suggestions/insight would be greatly appreciated!
Pat
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top