473,406 Members | 2,705 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,406 software developers and data experts.

avoiding - File download-security warning window when using response.writefile(filepath)

Hi

I used the code below to automatically open a pdf file when the user clicks
on a menu option.
It works great on local machine, but when I
uploaded it to hosting site and then tried it,
I get a 'File download-security warning' window popping up that ask if I
want to download or open the file.
It wants to download the aspx page itself , instead of the pdf file.
I'd would like it to offer to open the pdf file, or avoid this security
warning window all together.
I'm thinking it as something to do with the mime content type, but not sure.
Does anyone know how to do this?

Thanks,
CindyH

'Set the appropriate ContentType.

Response.ContentType = "Application/pdf"

'Get the physical path to the file.

Dim FilePath As String = MapPath("Reports\CurrentYear_ShootDates.pdf")

'Write the file directly to the HTTP content output stream.

Try

Response.WriteFile(FilePath)

Catch ex As Exception

Response.Redirect("DownloadPDFReader.aspx")

Response.End()

End Try

Response.End()


Jul 3 '06 #1
1 3250
Hello Cindy,

Well, Cindy, As yer using Server.MapPath() the file is obviously servable
by the web server directly.. just link to the file.

As for the security dialog, that is a client settings issue.

-Boo
Hi

I used the code below to automatically open a pdf file when the user
clicks
on a menu option.
It works great on local machine, but when I
uploaded it to hosting site and then tried it,
I get a 'File download-security warning' window popping up that ask if
I
want to download or open the file.
It wants to download the aspx page itself , instead of the pdf file.
I'd would like it to offer to open the pdf file, or avoid this
security
warning window all together.
I'm thinking it as something to do with the mime content type, but not
sure.
Does anyone know how to do this?
Thanks,
CindyH
'Set the appropriate ContentType.

Response.ContentType = "Application/pdf"

'Get the physical path to the file.

Dim FilePath As String = MapPath("Reports\CurrentYear_ShootDates.pdf")

'Write the file directly to the HTTP content output stream.

Try

Response.WriteFile(FilePath)

Catch ex As Exception

Response.Redirect("DownloadPDFReader.aspx")

Response.End()

End Try

Response.End()

Jul 4 '06 #2

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

Similar topics

4
by: Alexander Gilman Carver | last post by:
I have written a pair of scripts that are supposed to work together to display an index of files and then, upon the user choosing the files (with checkboxes on an HTML form submitted to itself),...
10
by: StevePBurgess | last post by:
I would like to make my downloads section unbrowsable (to users) but accessible to scripts. Can I deliver a file to a browser without linking to it's URL so that I can deliver files...
0
by: Sriram | last post by:
Hi, I have wriiten a program to transfer a binary file. After transfer. The file contents in the destination machine is getting changed. Please Help. Please advice if i am doing any...
15
by: TaeKyon | last post by:
I'm a python newbie; here are a few questions relative to a problem I'm trying to solve; I'm wandering if python is the best instrument or if awk or a mix of bash and sed would be better: 1) how...
9
by: mjakowlew | last post by:
Hi, I'm trying to use some string manipulation from a file's path. filepath='c:\documents\web\zope\file.ext' I need to extract everthing after the last '\' and save it. I've looked around...
4
by: Carsten Kraft | last post by:
Hello Newsgroup, I am searching for function which returns me filename from a string that has the file + filepath. ( string sFile = "C:\DIR\SUBDIR\TEST.XML" => TEST.XML) Is there a...
3
by: ek03 | last post by:
I have a web application that saves/loads XML documents. On occasion, an error is logged on the call to XmlDocument.Load: "process cannot access the file <filepath here> because it is being used by...
7
by: CCLeasing | last post by:
I would like to open a text file titled (c:\logs.txt). If the file doesn't exist i would like to create it. if it does exist i would like to append to it. I would like to insert a line into the...
2
by: r.z. | last post by:
I know I'm missing something and maybe someone will shed some light on this: I just wan't to read some info from a text file I create in Notepad. What should I use: basic_ifstream<char,...
7
by: ganeshp | last post by:
Code to delete the file is given below: File file = new File(filePath); file.delete(); But this code does not delete the file. Please post your thoughts on this issue. Regards, Ganesh
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.