why is "%2E" showing up instead of the dot?

M

.:mmac:.

My ASP page is doing something wierd, I think it has something to do with
the %2E replacing the dot in the file name But in addition, if I right click
the link and select "save as", the file extension is duplicated as
"Week20.pdf.pdf"
here is the relevant info:

<%
set directory=server.createobject("scripting.filesystemobject")
set allfiles=directory.getfolder(server.mappath("/MMM/Lesson/"))
' Lists all the files found in the directory
For each directoryfile in allFiles.files
%>
<a href=MMM/Lesson/ <%
' Write out the name of the document
response.write server.urlencode(directoryfile.name) %>><%
response.write directoryfile.name %>
</a>

This is how it turns up in the source of the published page"

<a href=MMM/Lesson/
Week20%2Epdf>Week20.pdf
</a>

The "%E2" is something I never noticed before.
does the code look right?
what about the duplicated extensions?
 
N

Nathan Sokalski

The %2E is there because of the

server.urlencode(directoryfile.name)

method. In most cases, this method is not necessary. It is usually only used
for QueryString techniques, but if all your filenames have is letters,
numbers, and the period, don't bother with it. I don't know for sure, but
because the filename has no extension in the code, this may be tricking the
browser into adding it a second time. After it adds it the second time, it
then interprets the %2E as a period when you select "save as". So my
suggestion is get rid of the server.urlencode() method so that your
generated code looks the way you want, and then see if this fixes the other
part.
 
R

Roland Hall

: My ASP page is doing something wierd, I think it has something to do with
: the %2E replacing the dot in the file name But in addition, if I right
click
: the link and select "save as", the file extension is duplicated as
: "Week20.pdf.pdf"
: here is the relevant info:
:
: <%
: set directory=server.createobject("scripting.filesystemobject")
: set allfiles=directory.getfolder(server.mappath("/MMM/Lesson/"))
: ' Lists all the files found in the directory
: For each directoryfile in allFiles.files
: %>
: <a href=MMM/Lesson/ <%
: ' Write out the name of the document
: response.write server.urlencode(directoryfile.name) %>><%
: response.write directoryfile.name %>
: </a>
:
: This is how it turns up in the source of the published page"
:
: <a href=MMM/Lesson/
: Week20%2Epdf>Week20.pdf
: </a>
:
: The "%E2" is something I never noticed before.
: does the code look right?
: what about the duplicated extensions?

Why are you encoding it?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
M

.:mmac:.

Nathan, Roland,

The short answer to "why" is because I don't know any better.
This was an example script I got from this forum a while ago that did what I
needed it to do which was to list all the files in a directory as clickable
links.
I was so excited to have it work I never questioned it.
What would be a better way?
 
R

Roland Hall

in message
: Nathan, Roland,
:
: The short answer to "why" is because I don't know any better.

and I thought I was the only one who fell victim to that... (O:=

: This was an example script I got from this forum a while ago that did what
I
: needed it to do which was to list all the files in a directory as
clickable
: links.
: I was so excited to have it work I never questioned it.
: What would be a better way?

As Nathan stated, remove the Server.URLEncode() and see if that solves your
issue. If not, post back and we'll go from there.

<%
set directory = Server.CreateObject("Scripting.FileSystemObject")
set allfiles = directory.GetFolder(Server.MapPath("/mmm/lesson/"))
For Each directoryfile in allFiles.files
Response.Write "<a href='/mmm/lesson/" & directoryfile.name & "'>" &
directoryfile.name & "</a>"
Next
%>

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
M

.:mmac:.

Just remove it?? not replace it with something?? OK will do. I'll let you
know how it works out monday.
 
B

Bob Lehmann

When you remove the urlencode you will need to enclose your href attribute
in quotes - which you should have been doing anyway.

<a href="MMM/Lesson/<% response.write server.urlencode(directoryfile.name)
%>">

Otherwise spaces in file names will break the link.

Bob Lehmann
 
R

Roland Hall

: Just remove it?? not replace it with something?? OK will do. I'll let you
: know how it works out monday.
:
: : > ".:mmac:." wrote in message
: > : > : Nathan, Roland,
: > :
: > : The short answer to "why" is because I don't know any better.
: >
: > and I thought I was the only one who fell victim to that... (O:=
: >
: > : This was an example script I got from this forum a while ago that did
: > what
: > I
: > : needed it to do which was to list all the files in a directory as
: > clickable
: > : links.
: > : I was so excited to have it work I never questioned it.
: > : What would be a better way?
: >
: > As Nathan stated, remove the Server.URLEncode() and see if that solves
: > your
: > issue. If not, post back and we'll go from there.
: >
: > <%
: > set directory = Server.CreateObject("Scripting.FileSystemObject")
: > set allfiles = directory.GetFolder(Server.MapPath("/mmm/lesson/"))
: > For Each directoryfile in allFiles.files
: > Response.Write "<a href='/mmm/lesson/" & directoryfile.name & "'>" &
: > directoryfile.name & "</a>"
: > Next
: > %>
:
I listed the modification for you to test with.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
M

.:mmac:.

Oops, so you did, Sorry about that.
It works perfectly now, thank you so much!
I will post another question about sorting the list in another thread.
Thank you all.
 
D

Dave Anderson

..:mmac:. said:
My ASP page is doing something wierd, I think it has something to do
with the %2E replacing the dot in the file name But in addition, if I
right click the link and select "save as", the file extension is
duplicated as "Week20.pdf.pdf"
...
<a href=MMM/Lesson/ <%
response.write server.urlencode(directoryfile.name) %>><%
response.write directoryfile.name %>
</a>

Are you just concerned about the way the text reads, or is this functionally
inoperable? When you use non-standard characters (such as spaces),
URLEncoding is necessary to conform to the recommendations in RFC1630:

Unsafe characters
In canonical form, certain characters such as spaces,
control characters, some characters whose ASCII code is
used differently in different national character variant
7 bit sets, and all 8bit characters beyond DEL (7F hex)
of the ISO Latin-1 set, shall not be used unencoded. This
is a recommendation for trouble-free interchange, and as
indicated below, the encoded set may be extended or
reduced.

http://www.ietf.org/rfc/rfc1630.txt



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
M

.:mmac:.

I was mostly concerned with it's appearance , but the side effect of having
two extensions in the "save as" function rendered it useless. There were no
spaces or odd characters used and the fix proposed (not encoding) did
resolve the problem.
now if I could just sort them properly...
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top