Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Setting filename including non ascii characters in asp download!

Reply
Thread Tools

Setting filename including non ascii characters in asp download!

 
 
Hans
Guest
Posts: n/a
 
      03-15-2005
Hi!

I have a classic ASP site (not ASP.NET) where the user is able to download
documents. The documents are stored inside an Oracle database set up for
UTF-8 encoding. In the VB6 code (COM+) that fetches the document I have code
like this (in my asp page I have set codepage=65001 which is utf-

GetObjectContext("Response").AddHeader "Content-Length",
rs("DocData").ActualSize
GetObjectContext("Response").contentType = "application/octet-stream"
GetObjectContext("Response").AddHeader "Content-Disposition", "attachment;
filename=""" & rs("orgfilename") & """"
GetObjectContext("Response").BinaryWrite
rs("DocData").GetChunk(rs("DocData").ActualSize)


The problem is that if the filename contains national characters they are
not shown correct in the save as dialog. I have tried to understand the RFC
documents about content-transfere-encoding but I have so far failed making
this work.

I can get this to work in IE if I URLPathEncode the filename (normal
urlencode is not working)
GetObjectContext("Response").AddHeader "Content-Disposition", "attachment;
filename=""" & GetObjectContext("Server").URLPathEncode(rs("orgfi lename")) &
""";"

Mozilla compatible browsers do not like this. They suggest the the filename
dok.asp, which is the name of the asp file that instantiate the com+
component that do the actual download.

Would really appreciate if someone can shed some light over this (an example
would be excellent).

Sorry to crosspost this message but I'm not sure if my problems is in my
code, IIS or maybe incorrect headers.

Regards
/Hans


 
Reply With Quote
 
 
 
 
Egbert Nierop \(MVP for IIS\)
Guest
Posts: n/a
 
      03-15-2005
"Hans" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi!
>
> I have a classic ASP site (not ASP.NET) where the user is able to download
>
> Would really appreciate if someone can shed some light over this (an
> example
> would be excellent).


This is really nasty since none of the browsers really follow the rules
http://support.microsoft.com/?id=267991


--
compatible web farm Session replacement for Asp and Asp.Net
http://www.nieropwebconsult.nl/asp_session_manager.htm


> Sorry to crosspost this message but I'm not sure if my problems is in my
> code, IIS or maybe incorrect headers.
>
> Regards
> /Hans
>
>


 
Reply With Quote
 
 
 
 
Hans
Guest
Posts: n/a
 
      03-15-2005
Hi Egbert and thanks for your reply!

My problem is not really that the save as dialog is not shown (in fact it is
shown). The main problem is that the filename I set in the content
disposition (including non ascii characters) is not shown in the save as
dialog. I can get this to work on my machine with IE but it fails with
Mozilla browsers (and I have read that the solution I have for IE that works
on my machine is not working on asian versions of IE
http://lists.w3.org/Archives/Public/...nMar/0000.html).

I tried to read the rfc2231 but I cannot get it to work.
http://www.faqs.org/rfcs/rfc2231.html

Regards
/Hans


 
Reply With Quote
 
Egbert Nierop \(MVP for IIS\)
Guest
Posts: n/a
 
      03-15-2005
"Hans" <(E-Mail Removed)> wrote in message
news:%23Aw%23$(E-Mail Removed)...
> Hi Egbert and thanks for your reply!
>
> My problem is not really that the save as dialog is not shown (in fact it
> is
> shown). The main problem is that the filename I set in the content


Right. I know what you mean.

> disposition (including non ascii characters) is not shown in the save as
> dialog. I can get this to work on my machine with IE but it fails with
> Mozilla browsers (and I have read that the solution I have for IE that
> works
> on my machine is not working on asian versions of IE
> http://lists.w3.org/Archives/Public/...nMar/0000.html).
>
> I tried to read the rfc2231 but I cannot get it to work.
> http://www.faqs.org/rfcs/rfc2231.html



Sorry but, browsers don't follow the rules. The only solution would be to
have an ISAPI sort of solution which generates the filename inside the url
instead of using a content-type solution, but that's an expensive joke.
(such filter would fake a filename using
http://www.yourserver.com/yourfile%20blah.doc or something like that.)


> Regards
> /Hans
>
>


 
Reply With Quote
 
Katarina WONG
Guest
Posts: n/a
 
      04-19-2005
Hello,

Good news: The solution to your problem exists !

Bad news: I can not provide you with working ASP code.

I ran into the very same problem just a few days ago when coding the
download fastcgi of our site. I have found the proper encoding for
Internet Explorer (only tested on Version 6 / WinXP so far) and for
Firefox (again only tested on WinXP yet).

For IE, I think you will find this page useful:

http://www.codeproject.com/aspnet/NonUSASCII.asp

I reproduced the filename encoding and its works great (all our code is
using the Ruby language).

This DOES NOT WORK for Firefox, so I test the HTTP_USER_AGENT value and
use the word encoding described in RFC2231. I use the Base64 encoding,
not the Quoted-printable which does not work.

For these two browsers everything is perfect, I tested it with really
weird (from my point of view of course ) filenames mixing french,
icelandic and korean.

As far as Opera is concerned, I have yet to find the correct way to
encode the file name. I can not imagine it is not possible, but I am
stuck on this browser.

Hope you find this helpful, feel free to contact me if you do not get it
working. I do not follow this newsgroup.

Katarina.

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex with ASCII and non-ASCII chars TOXiC Python 5 01-31-2007 04:48 PM
[FR/EN] how to convert the characters ASCII(0-255) to ASCII(0-127) Alextophi Perl Misc 8 12-30-2005 10:43 AM
Download file with a filename including national characters! Hans ASP General 0 02-03-2005 12:35 PM
Problem: Content-Disposition: attachment, with non-ASCII filename Costas Andriotis ASP .Net 0 10-15-2004 03:26 PM
zipfile module: problems with filename having non ascii characters vincent_delft@yahoo.com Python 4 08-22-2004 02:36 PM



Advertisments