download text/plain file without .txt extension

N

Nate Hekman

I have an aspx page that generates a file on the fly for a person to
download. It sends these http headers:

Content-Type: text/plain
Content-Disposition: attachment; filename="myfile.lic"

The file being downloaded is a license file and MUST be stored with that
..lic extension.

If I access this aspx page with IE, it prompts me if I want to open or save
the file. I choose save, and it prompts me for a location and filename, and
the default filename is indeed myfile.lic. But when it actually saves it,
it renames it to myfile.lic.txt.

Very frustrating! Incidentally, IE behaves this way, Firefox does not.
Firefox saves the file with the name I specified.

As a user, when I choose to save the file, I can force IE to use the exact
filename I want by surrounding it with double quotes: "myfile.lic". Then
the .txt doesn't get tacked on. But I can't force those extra quotes on
there in the Content-Disposition line.

Anyone have a solution?


Nate
 
P

Paul Clement

¤ I have an aspx page that generates a file on the fly for a person to
¤ download. It sends these http headers:
¤
¤ Content-Type: text/plain
¤ Content-Disposition: attachment; filename="myfile.lic"
¤
¤ The file being downloaded is a license file and MUST be stored with that
¤ .lic extension.
¤
¤ If I access this aspx page with IE, it prompts me if I want to open or save
¤ the file. I choose save, and it prompts me for a location and filename, and
¤ the default filename is indeed myfile.lic. But when it actually saves it,
¤ it renames it to myfile.lic.txt.
¤
¤ Very frustrating! Incidentally, IE behaves this way, Firefox does not.
¤ Firefox saves the file with the name I specified.
¤
¤ As a user, when I choose to save the file, I can force IE to use the exact
¤ filename I want by surrounding it with double quotes: "myfile.lic". Then
¤ the .txt doesn't get tacked on. But I can't force those extra quotes on
¤ there in the Content-Disposition line.
¤
¤ Anyone have a solution?

If I remember correctly IE does this for unknown file types. You might want to try registering the
..lic file extension with an application to see if it resolved the problem.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
N

Nate Hekman

That does resolve the problem, but it's not an acceptable solution to me.
It would work going forward but I need to deliver these license files to a
large number of customers who already have our software installed, and I
don't want them to have to run something else first to register the file
type before they can download the license files.

I have found that if I change the Content-Type to something non-standard,
such as:

Content-Type: application/mylicfile

IE no longer tries to tack on the .txt extension. Firefox and Netscape
continue to work correctly too. But am I breaking some standard by
manufacturing my own custom Content-Type? Will I run into trouble somewhere
else (perhaps some firewalls will filter out unknown content-types)?


Nate

P.S. If you know of a better forum to be asking these questions, please
suggest one.
 
P

Paul Clement

¤ That does resolve the problem, but it's not an acceptable solution to me.
¤ It would work going forward but I need to deliver these license files to a
¤ large number of customers who already have our software installed, and I
¤ don't want them to have to run something else first to register the file
¤ type before they can download the license files.
¤
¤ I have found that if I change the Content-Type to something non-standard,
¤ such as:
¤
¤ Content-Type: application/mylicfile
¤
¤ IE no longer tries to tack on the .txt extension. Firefox and Netscape
¤ continue to work correctly too. But am I breaking some standard by
¤ manufacturing my own custom Content-Type? Will I run into trouble somewhere
¤ else (perhaps some firewalls will filter out unknown content-types)?
¤

Could you use Response.AddHeader to specify the Content-Disposition value? I don't think it would
cause any issues using a custom Content-Type

¤ P.S. If you know of a better forum to be asking these questions, please
¤ suggest one.

I wouldn't consider myself an ASP expert so you may also want to try the
microsoft.public.inetserver.asp.general newsgroup as well to see if there are any other known
workarounds.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

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,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top