473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

URLEncode

I have to translate a URL so that the parameters in the URL include the
'special' characters for the ?, & and other features.

I have looked at the HttpServerUtility.URLEncode function and it seems to be
the correct method to call to conduct this translation. However I cannot
figure out how to get it to work.

I have tried
HttpServerUtility translate;
translate = System.Web.HttpContext.Current.Server;
string htmlUrlEncoded = translate.UrlEncode(htmlCode);
without success. I know I need to somehow create an object to actually do
the translation, but I am not running a webserver on the development machine
(which is why the Current.Server is probably failing).

Does anyone have any ideas?

Thanks in advance.
Nov 17 '05 #1
2 5806
use the HttpUtility class in the System.Web namespace
it has a static method UrlEncode(string) that does the job.

HTH
Cois
"Stephen Costanzo" <sx********@hotmail.com> wrote in message
news:OV**************@TK2MSFTNGP09.phx.gbl...
I have to translate a URL so that the parameters in the URL include the
'special' characters for the ?, & and other features.

I have looked at the HttpServerUtility.URLEncode function and it seems to
be
the correct method to call to conduct this translation. However I cannot
figure out how to get it to work.

I have tried
HttpServerUtility translate;
translate = System.Web.HttpContext.Current.Server;
string htmlUrlEncoded = translate.UrlEncode(htmlCode);
without success. I know I need to somehow create an object to actually do
the translation, but I am not running a webserver on the development
machine
(which is why the Current.Server is probably failing).

Does anyone have any ideas?

Thanks in advance.

Nov 17 '05 #2
Thank you very much, I was using the wrong class.

"Francois Bonin [MVP]" <th*****@gmail.com> wrote in message
news:e%****************@tk2msftngp13.phx.gbl...
use the HttpUtility class in the System.Web namespace
it has a static method UrlEncode(string) that does the job.

HTH
Cois
"Stephen Costanzo" <sx********@hotmail.com> wrote in message
news:OV**************@TK2MSFTNGP09.phx.gbl...
I have to translate a URL so that the parameters in the URL include the
'special' characters for the ?, & and other features.

I have looked at the HttpServerUtility.URLEncode function and it seems to be
the correct method to call to conduct this translation. However I cannot
figure out how to get it to work.

I have tried
HttpServerUtility translate;
translate = System.Web.HttpContext.Current.Server;
string htmlUrlEncoded = translate.UrlEncode(htmlCode);
without success. I know I need to somehow create an object to actually do the translation, but I am not running a webserver on the development
machine
(which is why the Current.Server is probably failing).

Does anyone have any ideas?

Thanks in advance.


Nov 17 '05 #3

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

Similar topics

3
by: Joshua Beall | last post by:
Hi All, I can see from the manual that the difference between urlencode and rawurlencode is that urlencode translates spaces to '+' characters, whereas rawurlencode translates it into it's hex...
3
by: JP SIngh | last post by:
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...
1
by: yawnmoth | last post by:
Any ideas as to why urlencode(addslashes(chr(0))) returns '%5C0'? It seems like it should return '%00' since that's what urlencode(chr(0)) returns. If not that, I could also see it returning...
1
by: Jim | last post by:
Hello, I'm trying to do urllib.urlencode() with unicode correctly, and I wonder if some kind person could set me straight? My understanding is that I am supposed to be able to urlencode...
4
by: Andreas Klemt | last post by:
Hello, is there a difference between System.Web.HttpUtility.UrlEncode and Server.UrlEncode ?
1
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("*") = *
4
by: djc | last post by:
1) I just recently used my own function which simply replaces cariage return / line feed characters with <br> tags for a large detail field before showing it via an asp.net page to preserve line...
0
by: Nathan Sokalski | last post by:
I am using Server.UrlEncode to make a piece of data safe to use as a QueryString. The data I am using is as follows: ratedpoem("title") Which returns the following String: "An Expression...
9
by: Mark_Rarefy | last post by:
Trying to urlencode this string: »ÁÏŒŠ˜ªŒ›h^aYh in vb.net (using either HttpUtility.UrlEncode(strEncrypted, encoding.UTF8) orServer.UrlEncode) I get:...
12
by: sleytr | last post by:
Hi, I'm trying to make a gui for a web service. Site using character in value of some fields. But I can't encode this character properly. >>> data = {'key':''} >>> urllib.urlencode(data)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.