473,563 Members | 2,722 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 7629
"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
2061
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...
5
5439
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
3146
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...
3
5145
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 & "?" &...
3
6445
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
6730
by: Andreas Klemt | last post by:
Hello, is there a difference between System.Web.HttpUtility.UrlEncode and Server.UrlEncode ?
1
1616
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
5361
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
1111
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...
0
7659
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...
0
7882
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. ...
0
8103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7945
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...
0
5208
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...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2079
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
916
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...

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.