473,700 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Server.Urlencod e

Hi All

I have users who upload files using my application using ASPUPLOAD
component.

My code uploads the file to a network location and once the upload is finish
I display the hyperlink using the following code

<a href=\myserver\ attachments\<%= server.urlencod e(rs("FileName" ))%>
target="_blank" ><%=rs("Filenam e")%>

Sometimes the hyperlinks works but sometimes it doesn't.

Should I be using server.urlencod e or not.

The problem is my users upload files with all sorts of filename slike
088-888 24(05)-774448.doc which includes spaces, special characters etc.

Can someone offer any help?

Regards
Jul 22 '05 #1
3 7648
"JP SIngh" <no**@none.co m> wrote in message
news:ug******** ******@TK2MSFTN GP09.phx.gbl...
I display the hyperlink using the following code

<a href=\myserver\ attachments\<%= server.urlencod e(rs("FileName" ))%>
target="_blank" ><%=rs("Filenam e")%>

Sometimes the hyperlinks works but sometimes it doesn't.
You need quotes around attribute values that mightcontain spaces,
as in

<a href="\myserver \attachments\<% =Server.URLEnco de(rs("FileName "))%>"
target="_blank" ><%=rs("Filenam e")%></a>
Should I be using server.urlencod e or not.


Probably and, if only for clarity, I'd prefer to see

<a href="<%= Server.URLEncod e( "/myserver/attachments/" & rs("FileName") )
%>" target="_blank" >
<%= Server.HTMLEnco de( rs("Filename") ) %>
</a>

HTH,
Phill W.
Jul 22 '05 #2
JP SIngh wrote:
Hi All

I have users who upload files using my application using ASPUPLOAD
component.

My code uploads the file to a network location and once the upload is
finish I display the hyperlink using the following code

<a href=\myserver\ attachments\<%= server.urlencod e(rs("FileName" ))%>
Why are you using backslashes in your href ? And why aren't you delimiting
the href value?
target="_blank" ><%=rs("Filenam e")%>

Sometimes the hyperlinks works but sometimes it doesn't.
Please try to describe your symptoms without using the words "doesn't work".

Should I be using server.urlencod e or not.

The problem is my users upload files with all sorts of filename slike
088-888 24(05)-774448.doc which includes spaces, special characters
etc.

So show us what the link looks like when you View Source in the browser.

When I try your example like this:
<a href=images/<%=server.urlen code("088-888 24(05)-774448.doc")%>
target="_blank" ><%="088-888 24(05)-774448.doc"%>
I get source that looks like this:
<a href=images/088%2D888+24%28 05%29%2D774448% 2Edoc
target="_blank" >088-888 24(05)-774448.doc

which yields this url:
http://webdev/test/images/088%2D888+...2D774448%2Edoc

This link will produce a Page Not Found. If I change the href to
<a href="images/<%="088-888 24(05)-774448.doc"%>"
target="_blank" ><%="088-888 24(05)-774448.doc"%>

I get a link that does open my test document.

So the quick answer is:
use the correct slashes in the url
don't use urlencode
delimit the href value

Now, if the link includes a querystring, the answer will change. The
querystring portion of the url will probably need to be urlencoded. Just the
part after the question mark.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #3

"JP SIngh" <no**@none.co m> wrote in message
news:ug******** ******@TK2MSFTN GP09.phx.gbl...
Hi All

I have users who upload files using my application using ASPUPLOAD
component.

My code uploads the file to a network location and once the upload is finish
I display the hyperlink using the following code

<a href=\myserver\ attachments\<%= server.urlencod e(rs("FileName" ))%>
target="_blank" ><%=rs("Filenam e")%>

Sometimes the hyperlinks works but sometimes it doesn't.

Should I be using server.urlencod e or not.

The problem is my users upload files with all sorts of filename slike
088-888 24(05)-774448.doc which includes spaces, special characters etc.

Can someone offer any help?

Regards
=============== ========
We re-write file names before saving them, replacing any problematic
characters with underscores.
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2065
by: Steve | last post by:
Hi All! I wonder if anyone could help me with the underlying logic of a problem I have. At the moment my working pages run like so --------------------------------------------------------- PAGE1: A form which gathers variables and POSTS them on to the next page. PAGE2: This page does a few simple calculations based on the variables gathered on PAGE1 and echoes the results to screen. It also contains a two
5
5463
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. I want to develop a webpage where people can send attachments that are stored on their local PC.
22
3169
by: Fawke101 | last post by:
Hi there, I am having trouble with some data that is ripped from a SQL database and displayed as a hyperlink. The hyperlink inserts the data into a querystring so the next page can read it. However, some of the data has apostrophies (') in it, so the page does not redirect properly (invalid syntax) because of the apostrophy. so i tried to use the URL encode to get around this to no avail - it doesnt
3
5150
by: George Hester | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en-us;301464 Look down at the MyPage.asp example. You will see that Microsoft does this: 'Costruct the URL for the current page s = "http://" s = s & Request.ServerVariables("HTTP_HOST") s = s & Request.ServerVariables("URL") If Request.QueryString.Count > 0 Then s = s & "?" & Request.QueryString
3
6455
by: KathyB | last post by:
Hi, Been reading a LOT about frames, variables, etc. I realize you can NOT use server.transfer with target frames (which are client)... I have a Parent frame containing Left and Right frames. IS IT POSSIBLE (and HOW please) to do the following: 4 text controls filled in by user in Left frame, with a button click event to:
4
6738
by: Andreas Klemt | last post by:
Hello, is there a difference between System.Web.HttpUtility.UrlEncode and Server.UrlEncode ?
1
1624
by: msn | last post by:
Invalid file name for monitoring: 'E:\inetpub\wwwroot\xxxxxxx\xxxxxxx\Server.UrlEncode("login.aspx'. File names for monitoring must have absolute paths, and no wildcards. Response.Redirect("Server.UrlEncode(""login.aspx?res=no&url=page2.aspx"")")
1
5369
by: Dario Sala | last post by:
Hi, what's the difference about Asp Server.UrlEncode and the Asp.Net Server.UrlEncode ? In asp: Server.UrlEncode("*") = %2A In Asp.Net: Server.UrlEncode("*") = *
0
1115
by: Tony | last post by:
Hello I have a working code for asp that I want to use now in asp.net. The code is included below. With this code I create a red bar on the bottom of an image, in which I give some comment on the image and the URL of the website. In the code image.asp I define the file name of the image (img), the comment (txt) and the url (url). In the later stage in the project, this info will be created dynamically depending on the requested image....
0
8731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8649
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7819
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5904
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4660
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2032
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.