Special Characters in URL, how to handle?

S

SMG

Hi All,
I have created an application which is working fine and is in about to
launch, now suddenly my mgmt says there are chances that Scrip ID( a
particular id and not prim key) may have special characters like '&,*,) or
/'

This data(field/key) I am passing this value as a querystring. e.g.

value to be passed : ABC
http://localhost/myProj/abc.aspx?ScripID=ABC
this works fine,

But when I have special characters like [ABC&D] then the value retrieved is
wrong it just retrieves ABC and not complete ID [ABC&D]
value to be passed : ABC&D
http://localhost/myProj/abc.aspx?ScripID=ABC&D

how do I overcome this, I know I can do it like we have %20 for space and
like wise for & there will be something, but this will be a major change to
my application, can I do this at one end some where in web.config or in aspx
page?

Regards,
Shailesh Gajare
 
M

MasterGaurav

Continuing from previous message:

Instead of
<a href="...?ScripID=ABC&D>Link
do a:

<form name="someName" action="abc.aspx" method="post">
<input type="hidden" name="ScripID" value="ABC&D">
<a href="javascript:someName.submit()">Link</a>
</form>

--
Cheers,
Gaurav Vaish
http://mastergaurav.blogspot.com
http://mastergaurav.org
-------------------------
 
S

SMG

Thanks Gaurav,
that means if I have five such type of links on the page either I have
to create 5 different forms or a single form which encorporate these links.
and If I have 500 - 600 pages with such links then what.

Isn't there some simple way?

Don't we have some thing in web.config?

I added following code in web.config file, still it functions the same way.

<globalization requestEncoding="utf-8" responseEncoding="utf-8" />

Any help?

Regards,
Shailesh Gajare
Continuing from previous message:

Instead of
<a href="...?ScripID=ABC&D>Link
do a:

<form name="someName" action="abc.aspx" method="post">
<input type="hidden" name="ScripID" value="ABC&D">
<a href="javascript:someName.submit()">Link</a>
</form>

--
Cheers,
Gaurav Vaish
http://mastergaurav.blogspot.com
http://mastergaurav.org
-------------------------
 
J

Juan T. Llibre

SMG,

You can encode/decode the URLs with the
respective URL methods ( URLencode/URL.decode ),


Dim text As String = "Juan's Link!"
Response.Write("<a href='some.aspx?id=" & Server.UrlEncode(text) & "'>Go There</a>")

but you will *not* be able to use neither "&" nor "=" nor "?"
in your URLs because those are *reserved* characters,
unless you escape them.

See : http://www.ietf.org/rfc/rfc2396.txt
Section 2.2. Reserved Characters
 
Joined
Aug 14, 2010
Messages
1
Reaction score
0
As others have pointed out above, you would have to encode/decode the URL. One way to test it online is using:

URLParser.com
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top