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

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?

Who is Participating?
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.

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?

factsmgtAuthor Commented:
text files are associated with Notepad. If I open the file through Windows explorer the file will open in Notepad.
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,

factsmgtAuthor Commented:
Does anyone have any insight on how to correct this on the client side?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.