473,395 Members | 1,568 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,395 software developers and data experts.

Some characters causing problems in HttpWebRequest

Hello,

I've created the domain registration system in ASP.NET. I'm using
HttpWebRequest to post the data to the registrar's server. So in the Post
string I'm passing the data like name, address, phone number etc.

The only two fields that are causing problems are the phone and fax fields.
My only guess here is that's because they start with the "+" sign. So the
string looks like this:

strPost=".....&phone=+7 095 2323344&fax=+7 095 7678899&......"

I guess the combination "=+" doesn't work.

The problem is that I must start any phone number with the "+" sign,
otherwise the registrar's system won't accept it. Any substitutes like
Chr(43) do not help here.

Is there a way to deal with this issue? I guess I should be able to pass any
string, but I had no luck so far.

I would greatly appreciate any help.

Thank you,

--
Peter Afonin
Nov 19 '05 #1
5 1319
You need to URLEncode the parameters. Spaces etc are not permitted in
URLs. You can use:

value = HttpUtility.UrlEncode(value)

to do the necessary conversions.

Kulgan.

Nov 19 '05 #2
Hi,

Some characters have special meanings and would cause confusion in a URL
which may result in the data being misinterpreted.
URL encoding is a way of providing a code to represent the textual

Use HttpUtility.UrlEncode( StringToEncode ); to encode data to post

myString = "Name=" + HttpUtility.UrlEncode( "doe" );
myString += "&SurName=" + HttpUtility.UrlEncode( "john" );
Use HttpUtility.UrlDecode( urlToDecode ); to decode data to post
in ASP.net: HttpServerUtility.UrlEncode

String MyURL;
MyURL = "http://www.contoso.com/articles.aspx?title = ASP.NET Examples";
Response.Write( "<A HREF = " + Server.UrlEncode(MyURL) + "> ASP.NET
Examples <br>" );

//NB: MyURL will be encoded as
"http%3a%2f%2fwww.contoso.com%2farticles.aspx%3fti tle+%3d+ASP.NET+Examples"
instead of
"http%3a%2f%2fwww.contoso.com%2farticles.aspx%3fti tle+=+ASP.NET+Examples"

Nicolas Guinet
"Peter Afonin" <pv*@speakeasy.net> a écrit dans le message de news:
uc**************@TK2MSFTNGP14.phx.gbl...
Hello,

I've created the domain registration system in ASP.NET. I'm using
HttpWebRequest to post the data to the registrar's server. So in the Post
string I'm passing the data like name, address, phone number etc.

The only two fields that are causing problems are the phone and fax
fields.
My only guess here is that's because they start with the "+" sign. So the
string looks like this:

strPost=".....&phone=+7 095 2323344&fax=+7 095 7678899&......"

I guess the combination "=+" doesn't work.

The problem is that I must start any phone number with the "+" sign,
otherwise the registrar's system won't accept it. Any substitutes like
Chr(43) do not help here.

Is there a way to deal with this issue? I guess I should be able to pass
any
string, but I had no luck so far.

I would greatly appreciate any help.

Thank you,

--
Peter Afonin

Nov 19 '05 #3
Hello,

Thank you all very much for your suggestions. I'll try them.

But what would happen with the spaces, for instance, in the address? They
are not allowed. I guess they also will be encoded?

Peter

"Nicolas Guinet" <n.******@wanadoo.fr> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

Some characters have special meanings and would cause confusion in a URL
which may result in the data being misinterpreted.
URL encoding is a way of providing a code to represent the textual

Use HttpUtility.UrlEncode( StringToEncode ); to encode data to post

myString = "Name=" + HttpUtility.UrlEncode( "doe" );
myString += "&SurName=" + HttpUtility.UrlEncode( "john" );
Use HttpUtility.UrlDecode( urlToDecode ); to decode data to post
in ASP.net: HttpServerUtility.UrlEncode

String MyURL;
MyURL = "http://www.contoso.com/articles.aspx?title = ASP.NET Examples";
Response.Write( "<A HREF = " + Server.UrlEncode(MyURL) + "> ASP.NET
Examples <br>" );

//NB: MyURL will be encoded as
"http%3a%2f%2fwww.contoso.com%2farticles.aspx%3fti tle+%3d+ASP.NET+Examples" instead of
"http%3a%2f%2fwww.contoso.com%2farticles.aspx%3fti tle+=+ASP.NET+Examples"

Nicolas Guinet
"Peter Afonin" <pv*@speakeasy.net> a écrit dans le message de news:
uc**************@TK2MSFTNGP14.phx.gbl...
Hello,

I've created the domain registration system in ASP.NET. I'm using
HttpWebRequest to post the data to the registrar's server. So in the Post string I'm passing the data like name, address, phone number etc.

The only two fields that are causing problems are the phone and fax
fields.
My only guess here is that's because they start with the "+" sign. So the string looks like this:

strPost=".....&phone=+7 095 2323344&fax=+7 095 7678899&......"

I guess the combination "=+" doesn't work.

The problem is that I must start any phone number with the "+" sign,
otherwise the registrar's system won't accept it. Any substitutes like
Chr(43) do not help here.

Is there a way to deal with this issue? I guess I should be able to pass
any
string, but I had no luck so far.

I would greatly appreciate any help.

Thank you,

--
Peter Afonin


Nov 19 '05 #4
Peter Afonin wrote:
Hello,

Thank you all very much for your suggestions. I'll try them.

But what would happen with the spaces, for instance, in the address?
They are not allowed. I guess they also will be encoded?


Sure.

Cheers,

--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #5
Thank you!

Peter

"Joerg Jooss" <ne********@joergjooss.de> wrote in message
news:xn****************@msnews.microsoft.com...
Peter Afonin wrote:
Hello,

Thank you all very much for your suggestions. I'll try them.

But what would happen with the spaces, for instance, in the address?
They are not allowed. I guess they also will be encoded?


Sure.

Cheers,

--
http://www.joergjooss.de
mailto:ne********@joergjooss.de

Nov 19 '05 #6

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

Similar topics

2
by: andy | last post by:
Greetings all. Problem: Have control characters mostly ^B which are loaded into a table in our database forming part or a narative field. In TOAD these appear as a thick bar - kind of like a pipe...
7
by: George Hester | last post by:
Best done using Microsoft Internet Explorer but I believe Netscape may do OK not sure. I have one itsy bitsy little problem here. The tabbing? No forget that I got a few gray hairs with that and...
3
by: Adam Stirk | last post by:
Hi, I am trying to download a image that is generated by PHP using HttpWebRequest, I believe the server uses cookies to generate the image, but I keep getting the error image from the server. ...
13
by: Jason Manfield | last post by:
For some URLs (e.g.http://v3.espacenet.com/origdoc?DB=EPODOC&IDX=WO2005028634&F=0&QPN=WO2005028634), the content length for the HttpWebResponse I get with request.GetResponse in empty. The...
8
by: Peter Afonin | last post by:
Hello, I've created the domain registration system in ASP.NET. I'm using HttpWebRequest to post the data to the registrar's server. So in the Post string I'm passing the data like name, address,...
6
by: Oliver | last post by:
I have a very wired problem requesting one specific url from within my application. I have struggeled with this for 5 hours now, and searched google withour any luck, so i hope that someone are...
1
by: romiko2000 | last post by:
Hi Folks, I got a weird problem, I create an XMLWriter to post a document via the webrequest stream and after running a network trace, I notice the data is prefixed with 3 invalid characters! ...
3
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
I'm drawing text using the DrawString method. I need a way to go back and erase one or more characters. As a first thought it seemed that one way to do it would be to go back to the character(s)...
3
by: matadon | last post by:
Hi, I am writing a C# app. I have a finite (~50) set of URLs that I am continuously polling in a circular manner. I would like to do this in a way that can send out each of the requests and get...
4
by: BG Mahesh | last post by:
hi We are using the normal html controls (textarea) in the posting form. The form page has the utf-8 character set. Users are copying the text from MS Word or Openoffice doc etc. Our PHP...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.