Community discussion forum
Send Binary Data from ASP
-
This thread is for discussions of Send Binary Data from ASP.
-
Advertisement
Simply the fastest line-level profiler for .NET ever
“The low overhead means it has minimal impact on the execution of my program”
Mark Everest, Development Team Leader, Renault F1 Team Ltd.Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now
-
Hi,
I tried your tutorial. Works great on Windows and IE 5.5+. But my Mac running IE 5.1 doesn't work. The Save As dialog did not show up on Mac.
Please help. -
I don't have immediate access to a Mac to try this out. Let me do some digging and get back to you.
-
So I've been cogitating on this for awhile. There is nothing sophisticated in the HTML code (at least, not from a standards perspective), so the answer has to lie elsewhere. Had me stumped. But as I was showering this morning, it struck me. Maybe it has something to do with the content type values. I don't know what they are supposed to be for the Macintosh. You might want to try setting it to 'application/octet-stream'. That is sort of the default type for use in Mac's (I believe).
Hope this helps. -
Yes, I did use "octet-stream" as the content type. But the Mac IE 5.1 still does not recognize it as a "File->Save As" action. Is there a way at all to make this work with the Mac? It seems very happy on Windows.
Quote: [1]Posted by LACanadian on 26 May 2002 02:43 AM[/1]
So I've been cogitating on this for awhile. There is nothing sophisticated in the HTML code (at least, not from a standards perspective), so the answer has to lie elsewhere. Had me stumped. But as I was showering this morning, it struck me. Maybe it has something to do with the content type values. I don't know what they are supposed to be for the Macintosh. You might want to try setting it to 'application/octet-stream'. That is sort of the default type for use in Mac's (I believe).
Hope this helps.
-
Have you tried adding another header of the form 'Content-Disposition: filename="fname"' to the request?
-
Use this code and you do not need any special components or any other techniques.
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile("c:\inetpub\file.gif", 1, 0)
Do While a.AtEndOfStream <>True
retstring = a.Read(1)
response.binarywrite(chrb(asc(retstring)))
loop
a.close
Off course this will slow your server because it must convert (in example) 10 000 of bytes, but i do not think that you will feel it (also with big files).
-
I followed the example, but when the dialog box pops up in the browser it shows that it wants to download the file that is an ASP page it-self that contains this code, I can't get it to download PDF file.
Please help!
Nevermind, I found it.
Thanks. -
I'm having the same exact problem.. " dialog box pops up in the browser it shows that it wants to download the file that is an ASP page it-self that contains this code, I can't get it to download PDF file. " I need help with this ASAP...
I"m using a third party software called "activepdf toolkit" to create the pdf and put it in memory. After it is done creating, i use this code to display the pdf to the browser.
response.ContentType = "application/pdf"
response.AddHeader "Content-Type", "application/pdf"
response.addHeader "Content-Disposition", "filename=part"&hour(Now)&""&minute(Now)&".PDF"
This works fine in IE 5.0 and above for windows.. but not on the mac version.
Thanks in advance.. -
here is my code that works, it in JavaScript (shouldn't make any difference):
<%@ Language=JavaScript %>
<%
// some code to get binary pdf.
Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment; filename=" + tFileName);
Response.ContentType = "application/pdf";
Response.BinaryWrite(tPDF);
%>
Make sure before these lines you don't write anything into response and remove all html code from this page, try this by only leaving server side code, this is how I got mine working.
good luck. -
I was wondering. Is there any settings I need to do on the mac to enable the opening of a pdf. I am running MAC OS X , IE 5.2. I was reading online for all the settings for the mac browser to open up a pdf but it doesn't work. Any help is appreciated. Thanks
-
?????????? ?? ?? ??????? http://www.thaiirc.com
-
here is my code:
Dim tFileName
tFileName = "web_report.pdf"
Response.Clear
Response.Buffer = True
Response.AddHeader "Content-Disposition", "attachment; filename=" & tFileName
Response.ContentType = "application/pdf"
Response.BinaryWrite tPDF
it doesn't open a PDF file in my browser window?
can you please help!?
I need it ASAP.
Thank you! -
Thanks for the code , maybe im being a little thick , but there is no mention of the
oUtilityObject referenced within this example code.
I managed to work it out using this article and another from here ..
http://www.developerfusion.com/show/2542
My working version of these two pieces of code is as follows ...
Code: <%
Function getBinaryFile(strFilePath)
Dim TypeBinary, oStream
TypeBinary = 1 ' Indicates a binary file
' Create the object
Set oStream = Server.CreateObject("ADODB.Stream")
' Open our file
oStream.Open
' Retreive binary data from the file
oStream.Type = TypeBinary
oStream.LoadFromFile strFilePath
' Return the binary data to the caller
getBinaryFile = oStream.read
' Destroy the ADO object
Set oStream = Nothing
End Function
sServerFile = Server.MapPath("/therealfilelocation/private/CTC012.pdf")
'sFile = "CTC012.pdf"
Response.Buffer = True
Response.Clear
' I want the file displayed within the browser so dont specify a filename
'Response.AddHeader "content-disposition", "attachment; filename=" & sFile
Response.ContentType = "application/pdf"
Response.BinaryWrite getBinaryFile(Server.MapPath("/therealfilelocation/private/CTC012.pdf"))
Response.end
%>
It is worth noting that when I specified a filename if the user chose the "open file" option instead of the "save file" option when prompted by Internet Explorer Acrobat reader displays the error "File Not Found" after IE has downloaded the data.
To get around this and to make the page look nicer , i commented out the filename part.
This means Internet Explorer Opens it via Acrobat in the browser (if configured).
I have not tested MACS or other Browsers yet.
Hope this helps someone. -
To clarify, oUtilityObject simply contains the code on http://www.developerfusion.com/show/2235/2/, which is compiled into a VB DLL, and then called from the ASP code on the next page.
-
That's due to the
Response.AddHeader "Content-Disposition", "attachment; filename=" & tFileName
line. Remove it, and it should work fine. -
thank you.
-
Thanks Scott...
I've been struggling with this for weeks, reading various articles and trying different things.
Your code WORKS!!!
Very much appreciate you taking the time to post the solution. -
Any ideas why this code won't work on the Mac?
-
I am having the same problem with opening a pdf in IE on the Mac. Did you ever figure this out
-
I got a friend to check this code out on a MAC , it worked perfectly.
I believe it was os9 but I wouldnt swear on it , but I do know it was IE on the MAC.
I also tested the code against netscape 6.2 and Opera 6.05 , working fine.
Regards
Scott. -
I've tried to follow the direction in this link but the Adobe Plug-in does not come up as an option in the list of available Plug-ins:
http://www.adobe.com/support/techdocs/93f2.htm
Is there different Adobe plug-ins for IE vs. Netscape?
Did you have to configure IE on the Mac to get this to work? Currently, when I run the code it downloads an asp page to the desktop instead of the pdf. The name of the asp file it is downloading is the name of the page I am running the script in.
Any assistance on the subject would be most appreciated. Thanks.
Jerry -
I am trying to create a sub at the dll level and just give it the strFilePath as a physical path...
Is there a way NOT to force it save/open but open it IN the IE? I tried removing the filename, but doesn't seem to work. I tried to remove the header and it worked. Is it a stable approach?
By the way, the Sub is configured only for jpg files. I will add the other files after I get this fixed.
Any help appreciated very much.
Thanks
Code:
Public Sub SendFile(ByVal strFilePath As String, _
Optional strFileName As String, _
Optional bForce As Boolean = False)
goResponse.Buffer = True
goResponse.Clear
If strFileName = "" Then _
strFileName = Mid(strFilePath, InStrRev(strFilePath, "\") + 1)
If bForce = False Then _
strFileName = ""
goResponse.AddHeader "content-disposition", "attachment; filename=" & strFileName
goResponse.ContentType = "image/jpeg"
Dim vStream As Variant
vStream = ReadBinaryFile(strFilePath)
goResponse.BinaryWrite (vStream)
goResponse.End
End Sub
Private Function ReadBinaryFile(ByVal strFileName As String) As Variant
Dim lFileLength As Long
Dim lFileNo As Long
Dim aBytes() As Byte
'On Error GoTo ErrHandler
lFileNo = FreeFile()
Open strFileName For Binary Access Read As #lFileNo
FileLength = FileLen(strFileName)
ReDim aBytes(lFileLength)
Get #lFileNo, , aBytes
Close #FileNo
ReadBinaryFile = aBytes
End Function
-
better then to remove this line:
Response.AddHeader "content-disposition","attachement; filename=some.pdf"
is to change it to look like this
Response.AddHeader "content-disposition","inline; filename=some.pdf" -
Hi,
i've read your article and your solution works fine
allthough I do not understand why i am not asked if I want to save the document.
However my real problem is that I need to retrieve the PDF file first from a remote site
Any idea how to achieve this ?
best regards -
I'm not exactly sure what you're asking. Are you saying that the server side code needs to retrieve the PDF file from a different URL before returning it in the Response stream?
-
yes exactly.
The ASP page gets some parameters from a form.
These paramters are used to do a lookup in a database.
A url is created to connect to an application server. This server is only accessible from our web server, not from the clients browser.
So the asp page should issue an http request with an url with parameters to the application server who returns a pdf stream hi is building. This stream is then forwarded to the client browser
Is this possible ?
and how ? -
The request from the web server to the application server could be done by using the ServerXMLHTTP object that is part of MSXML. That object allows you to programmatically make a request to a web server. I have an article on DevFusion that talks about how to do this. It's a synchronous call, so the response from the server is available to you immediately. This result could then be fed into the output stream from the web server back to the initial requester.
I haven't tried all of this together, but it should work
-
THanks for the tip.
Were acn I get this object, and will it run on ASP or does it require ASP.Net ?
Being XML, is it able to handle binary streams ?
Can you post a link to the article ?
Best regards -
The object comes with IE5.5 and higher (I believe). There is an XMLHTTP object that came with IE5, but it is single threaded, so not good for use in a server environment.
It runs on ASP. The technique used for ASP.NET is a different one. So while it could still be used, it is not the best approach to take.
Don't let the fact that has XML in the name fool you. I think the only reason that it's there is because the object is part of MSXML. It has no problems with binary streams.
The article can be found at http://www.developerfusion.com/show/3272/. Don't let the fact that it is written for Visual Basic slow you down. The same technique works in ASP. -
Sorry to be stupid :-)
But i still have problems
I heve the code here after
The aim is to retrieve a dynamically generated PDF from another server by submitting a POST with the params.
The the result od this post, the PDF stream should be sent to the client browser.
if I do a response.BinaryWrite strValue, or a response.Write, i get this error message
'An unhandled data type was encountered.'
If a don't use a write but only have a look at the result I get
'status : 200statustext : OK ' so looks ok Here is the code
xmlhttp.send "TYPEDOC=STREAM"
strValue = xmlhttp.responseStream
'response.write "number of chars " & len(strValue) & "<br>"
response.write "status : " & xmlhttp.status
response.write "statustext : " & xmlhttp.statustext -
I am having the same problem where it wants to save the asp file, not the pdf file. ???
Does anyone know why this is?
Quote: [1]Posted by acuze104 on 16 Dec 2002 06:31 PM[/1]
I'm having the same exact problem.. " dialog box pops up in the browser it shows that it wants to download the file that is an ASP page it-self that contains this code, I can't get it to download PDF file. " I need help with this ASAP...
I"m using a third party software called "activepdf toolkit" to create the pdf and put it in memory. After it is done creating, i use this code to display the pdf to the browser.
response.ContentType = "application/pdf"
response.AddHeader "Content-Type", "application/pdf"
response.addHeader "Content-Disposition", "filename=part"&hour(Now)&""&minute(Now)&".PDF"
This works fine in IE 5.0 and above for windows.. but not on the mac version.
Thanks in advance..
-
This is a really bad function if you are sending files that are large, or where speed matters. For instance, I tested this function on a managed server where I received a download rate of around 4k per second. However, if I browsed directly to the file instead of having the function pass it to me I achieve speeds of around 80 to 100k per second. That is a considerable slowdown and it is very inneficient to send binary data one byte at a time
-
I have same code and it doesn't work. White screen appear instead of PDF document :-(
-
I have same code and it doesn't work. White screen appear instead of PDF document :-(
-
cboy, if you have Adobe Reader 6 on your system the browser plugin sometimes get screwed, re-run the install of Adobe Reader and try again, it should be fine.
-victor -
I've discovered strange thing, that this code doesn't work only on
machine where Visual Studio .NET 2005 (Whidbey) is installed.
I check it on several computers and it is true.
When I remove VS2005 and install only .NET-2.0,
which is supplied whith VS 2005. Everything goes well.
I use VS2005 alpha version which is little bit raw and has bugs -
I've created a database in Access 2000 and inserted my pdf files as OLE objects from within the database table view but when I get them out I have problems.
It seems as my files have extra information at the head of them. From what I gather a pdf file's binary data should start with '%PDF-' but the first couple of lines of mine seem to be as shown below. Is this an additional header or something that needs to be removed? (I got this data simply by removing the content type so that the binary data would be written as text).
The code works fine on the original file but not when I get it from the database.
Code:
Dim EAMSDatabase
Set EAMSDatabase = Server.CreateObject("ADODB.connection")
EAMSDatabase.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\Inetpub\wwwroot\db.mdb")
Set objRS = EAMSDatabase.Execute("select pdf_object from articles where EntryId=1")
Response.Buffer = True
Response.Clear
Response.ContentType = "application/pdf"
Response.BinaryWrite objRS(0)
Response.end
EAMS_Database.Close
Any ideas?
Code: 7%ÿÿÿÿAcrobat DocumentAcroExch.DocumentAcroExch.DocumentÔÐÏࡱá>þÿ þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýÿÿÿèþÿÿÿáýÿÿÿýÿÿÿýÿÿÿ !"#$%&'()+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~€Root Entryÿÿÿÿÿÿÿÿeʸü¡Ð…DESTУƒóÄOle ÿÿÿÿÿÿÿÿÿÿÿÿContentsÿÿÿÿ ²OlePres000ÿÿÿÿÿÿÿÿPþÿÿÿ !"#$%&'()*+,-./0123456789:þÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ«‹Lp4õ—XäÂzÈÈr“DÅ„öó~9šÇ¤]Ë;Ci’F7¿®êoÿÿÿÿÿÿÿÿì !’ ÿÿÿ¥A ƈ 9( @ÿÿÿ ¥9II3ò%9999444449999-]IŸ%49494444999-]Ÿ%%%%%%%%%%%%%%%$ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ?ÿÿÿ!A Ff ‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ !"#$%&'()+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàþÿÿÿâãäåæçþÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ%PDF-1.4 %âãÏÓ 143 0 obj<>stream xÚ¬WKoÛFæßèmâƒÁ}?‚ €,hàØM$9(>°2! uDƒ’ûÏ·ývWÑ‹JEE>ÃÝï›gv—B#!‰3A’“✤ åIIÚx’ŠŒ°$-¯H:²J’ôä”&ÅÈs y‘‹•„uÎ5¸q!Àä¶kuŒ¾X~ƒKâN¿ÝUx~/‹ÛÉt U‚6¦·‘ÉÊš¹ªç¼zÊ;÷óWá0xMÎ8u&5]U—ßPh”®RC†mÓôï ”s 9 Fíš·êG±u{xÞ +•¤Fû©9¯nŸáxpdÖÒBc ¡E&û5 -
Is it possible to output the content of the file in the browser instead of pushing
the file for downloading?
Thanks -
This worked for me....
Response.ContentType = "application/msword"
Response.OutputStream.Write(buffer, 0, buffer.length)....where buffer is a byte array.
Don't add a Response.AddHeader
Make sure the checkbox "Always ask before opening this type of file" in a download dialog isn't clicked. -
hi
i tried the followin code in a page using vb
Dim tFileName
tFileName = "1.pdf"
Response.Clear
Response.Buffer = True
'Response.AddHeader "Content-Disposition", "attachment; filename=" & tFileName
Response.ContentType = "application/pdf"
Response.BinaryWrite(tFileName)
but it throws error invalid cast -
rocko_hunk, sure it will throw an error on this line: Response.BinaryWrite(tFileName)
Because, tFileName is a string and you need to pass to Response.BinaryWrite method a binary array with proper PDF document.
In VS2003 I have the following code that works w/o problems:
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(tPDF);
Response.End();
Where tPDF is a binary array that contains a PDF document. -
hi below is the code u sent
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(tPDF);
Response.End();
I know very well that I need to tPDF the content of pdf
can you please tell me how to store the content of the (let us say a1.pdf) pdf file in an array
so that i could pass it to the Response.BinaryWrite() method -
I am having the exact same problem except my code works on a Windows XP computer but does not work in Windows 2000. In XP, acrobat opens in my web application and the pdf displays as it should. In 2000 using the exact same code, I get the "file download" message box. If I open the file, it opens as an aspx file showing the code that would have been used to generate the pdf. In fact, if I change the extension of the aspx file to pdf, it will open as it should in acrobat. Here is my code. Must be a bug in Windows or IE?
// Generate Crystal Report in PDF Format
ContainerContents Report = new ContainerContents();
Report.SetDataSource(ds);
CrystalDecisions.Shared.ExportOptions RptExportOptions =
new CrystalDecisions.Shared.ExportOptions();
RptExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
CrystalDecisions.Shared.ExportRequestContext RptExportRequestContext =
new CrystalDecisions.Shared.ExportRequestContext();
RptExportRequestContext.ExportInfo = RptExportOptions;
System.IO.Stream RptStream = null;
RptStream = Report.FormatEngine.ExportToStream(RptExportRequestContext);
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = @"application/pdf";
Byte[] RptBuffer = new Byte[RptStream.Length];
RptStream.Read(RptBuffer, 0, (int)RptStream.Length);
Response.BinaryWrite(RptBuffer);
Response.End(); -
gjohnson, I can think of two things.
1. check XP/IE security settings
2. Reinstall Adobe Reader. -
Hi, thanks for the code. i tested it in my ASP site.
i find however the code works for pdf files of around <80K size. Once the pdf files goes past 80K, the code bombs. All i see in the requesting browser is a 'page not found'.
Could it be related to the buffer size? Any idea?
Thanks, CK
Quote: [1]Posted by scottuk on 17 Jan 2003 07:26 AM[/1]
Thanks for the code , maybe im being a little thick , but there is no mention of the
oUtilityObject referenced within this example code.
I managed to work it out using this article and another from here ..
http://www.developerfusion.com/show/2542
My working version of these two pieces of code is as follows ...
Code: <%
Function getBinaryFile(strFilePath)
Dim TypeBinary, oStream
TypeBinary = 1 ' Indicates a binary file
' Create the object
Set oStream = Server.CreateObject("ADODB.Stream")
' Open our file
oStream.Open
' Retreive binary data from the file
oStream.Type = TypeBinary
oStream.LoadFromFile strFilePath
' Return the binary data to the caller
getBinaryFile = oStream.read
' Destroy the ADO object
Set oStream = Nothing
End Function
sServerFile = Server.MapPath("/therealfilelocation/private/CTC012.pdf")
'sFile = "CTC012.pdf"
Response.Buffer = True
Response.Clear
' I want the file displayed within the browser so dont specify a filename
'Response.AddHeader "content-disposition", "attachment; filename=" & sFile
Response.ContentType = "application/pdf"
Response.BinaryWrite getBinaryFile(Server.MapPath("/therealfilelocation/private/CTC012.pdf"))
Response.end
%>
It is worth noting that when I specified a filename if the user chose the "open file" option instead of the "save file" option when prompted by Internet Explorer Acrobat reader displays the error "File Not Found" after IE has downloaded the data.
To get around this and to make the page look nicer , i commented out the filename part.
This means Internet Explorer Opens it via Acrobat in the browser (if configured).
I have not tested MACS or other Browsers yet.
Hope this helps someone.
Post a reply
Related discussion
-
How to modify desktop app to work from many computers
by systeko (0 replies)
-
how to select item to datagrid from textbox
by chandradev1 (50 replies)
-
Problem after strong naming an assembly
by rinkurathor1 (0 replies)
-
Very slow inserts using SqlCommand.ExecuteNonQuery()
by porchelvi (1 replies)
-
VB.net class to connect to sql database
by senol01 (2 replies)
Related articles
Quick links
Recent activity
- shweta k replied to Is it possible to send SMS...
- Aquila Sands replied to Key_Press() event for text box
- Jake Rabbit replied to Rename all kind of files an...
- Pero Perovic replied to How to modify desktop app t...
- chandradev prasad replied to how to select item to datag...
- Adeel Saleem replied to i have struck with my proj...
Enter your message below
Sign in or Join us (it's free).