encoding file name not working with # sign

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

A .NET 1.1 web app...

I create a hyperlink with a complete filename, and the target is for a new
window to open. Right now the filenames are all PDF files.
Everything works fine, the PDF opens in a new window - until a filename
containing a # sign is clicked. A window still opens up but I get the
dreaded 'Page cannot be displayed' error. I wrapped the filename around the
encode method so that the # sign is properly encoded, but the error persists!!

The user can right click on the link, save the file to their hard drive and
when they double click on that file, naturally Acrobat Reader opens the file
with no problem.

Any help on this? What can I do to ge the file to open on a hyperlink click?

Thanks in advance - Hedge
 
Hello Tony,
Hello,

A .NET 1.1 web app...

I create a hyperlink with a complete filename, and the target is for a
new
window to open. Right now the filenames are all PDF files.
Everything works fine, the PDF opens in a new window - until a
filename
containing a # sign is clicked. A window still opens up but I get the
dreaded 'Page cannot be displayed' error. I wrapped the filename
around the
encode method so that the # sign is properly encoded, but the error
persists!!
The user can right click on the link, save the file to their hard
drive and when they double click on that file, naturally Acrobat
Reader opens the file with no problem.

Any help on this? What can I do to ge the file to open on a hyperlink
click?

Are you sure this isn't a client-side (read: browser) issue? Do you even
get a page hit on the server when clicking such a link?

Cheers,
 
Hello Tony,

It's a well-known problem with # sign. I've never met solution, besides don't
use # in path
Nothing else.

TH> I create a hyperlink with a complete filename, and the target is for
TH> a new
TH> window to open. Right now the filenames are all PDF files.
TH> Everything works fine, the PDF opens in a new window - until a
TH> filename
TH> containing a # sign is clicked. A window still opens up but I get
TH> the
TH> dreaded 'Page cannot be displayed' error. I wrapped the filename
TH> around the
TH> encode method so that the # sign is properly encoded, but the error
TH> persists!!
TH> The user can right click on the link, save the file to their hard
TH> drive and when they double click on that file, naturally Acrobat
TH> Reader opens the file with no problem.

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
Hello Joerg,
I don't believe it is a client-side issue because everything works fine as
long as the # sign is not in the filename. In other words, the new window
will open up, Acrobat Reader will load, and the file is displayed.

Thanks - Hedge
 
Hello Michael,

As a 'workaround', I've told the users not to create filenames with # signs
in them. It is just a habit that they have to break.

I think you are right about a solution not existing, I've yet to find one.

Thanks - Tony
 
Hello again,

More info: IE seems to mis-interpret the # sign in a filename as a bookmark.
 
The # sign is to specifiy a location inside a document. IMO it won't work in
a href link. A workaround could be to have the page stream the file to the
browser ... (using the "attachment;filename=myfile#something.pdf" content
disposition header).
 
Hello Tony,
Hello Joerg,
I don't believe it is a client-side issue because everything works
fine as long as the # sign is not in the filename.

That doesn't proof anything, does it? It could be that exactly this kind
of string is not handled correctly by thr browser. I don't say it's very
likely, but simply firing up another browser will certainly show what's going
on. You can also check whether you get a server hit if that error shows up.

Cheers,
 
Back
Top