Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Text files opening up as html instead of Notepad/Wordpad in IE

Posted on 2004-10-22
Medium Priority
Last Modified: 2008-01-16
I have a web application that allows a user to download a etxt file within their browser. Several end users have reported that after applying XP SP2 the files open up in IE as html. Is there a way to change this so that the IE uses Notepad/Wordpad to open the files?

Question by:factsmgt
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 12381148
Are text files associated to IExplorer?

You can view that in the files properties, in the 1st tab under opens with APP_NAME -> hit the change button, in case it is associated to IExplorer.

is that the issue?


Author Comment

ID: 12382222
text files are associated with Notepad. If I open the file through Windows explorer the file will open in Notepad.

Expert Comment

ID: 12387472
Here ya go:

Response.Buffer = True

strFileName=request("strFileName")        ' Set file name
strFilePath=server.mappath(strFilename) ' Set path of file
set fso=createobject("scripting.filesystemobject")
set f=fso.getfile(strfilepath)
strFileSize = f.size
set f=nothing: set fso=nothing
Const adTypeBinary = 1
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
strFileType = "application/text" ' change to the correct content type for your file
Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
Response.AddHeader "Content-Length", strFileSize
Response.Charset = "UTF-8"
'Response.ContentType = strFileType
Response.BinaryWrite objStream.Read
Set objStream = Nothing

make a new page.  paste this script into it.  call it "forcedownload.asp".  make the link on your file something like:

<a href="forcedownload.asp?strFileName=my_text_file.txt">my text file</a>

It will force the user to download the file rather than opening it up in the browser.  Very nice.  I got it from some site a long time ago.  (maybe even this one)  It has saved me a huge amount of trouble.  Especially because you can set the file path to someplace other than your website.  Places where you don't want people to be able to browse to.  

Good luck,


Author Comment

ID: 12535564
Does anyone have any insight on how to correct this on the client side?

Accepted Solution

Danielcmorris earned 500 total points
ID: 12536490
It would be an incredible pain in the butt.  You may be able to set your user's computers to disassociate IE with txt files, but I couldn't tell you how to do it.  

If you REALLY wanted to fix it so your XP users would get notepad, you can create a little activex object that would pull the document off your site, save it to a temp file, then open that file with notepad.

Then again, you'd have to screen the users so only Windows users would get the ActiveX.  For linux and mac, well.... a Java app.  All around Yuck.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question