Skip Navigation Links
Skip navigation links
Blog
Document Center
News
Reports
Search
Sites
Other Blogs
There are no items in this list.
Code Integrators > Blog > Categories
Encode URLs and Query Strings

There are many times that you will want to pass query parameters in a query string. The best practice approach to do this is to make sure that you URL Encode them so that any special characters are safely translated. You can decode them on the receiving side.

Encoding Example:

string PageWithQueryString = @"Bad & {Worse}";

PageWithQueryString = @"NewPage.aspx?ID=" + Server.UrlEncode(PageWithQueryString);

Response.Redirect(PageWithQueryString, false);

 

Decoding Example:

string QryString = Server.UrlDecode(Request.QueryString["ID"].ToString());

 

Table of Characters:

ASCII Value

URL-encode

ASCII Value

URL-encode

ASCII Value

URL-encode

æ

%00

0

%30

`

%60

  

%01

1

%31

a

%61

  

%02

2

%32

b

%62

  

%03

3

%33

c

%63

  

%04

4

%34

d

%64

  

%05

5

%35

e

%65

  

%06

6

%36

f

%66

  

%07

7

%37

g

%67

backspace

%08

8

%38

h

%68

tab

%09

9

%39

i

%69

linefeed

%0a

:

%3a

j

%6a

  

%0b

;

%3b

k

%6b

  

%0c

<

%3c

l

%6c

c return

%0d

=

%3d

m

%6d

  

%0e

>

%3e

n

%6e

  

%0f

?

%3f

o

%6f

  

%10

@

%40

p

%70

  

%11

A

%41

q

%71

  

%12

B

%42

r

%72

  

%13

C

%43

s

%73

  

%14

D

%44

t

%74

  

%15

E

%45

u

%75

  

%16

F

%46

v

%76

  

%17

G

%47

w

%77

  

%18

H

%48

x

%78

  

%19

I

%49

y

%79

  

%1a

J

%4a

z

%7a

  

%1b

K

%4b

{

%7b

  

%1c

L

%4c

|

%7c

  

%1d

M

%4d

}

%7d

  

%1e

N

%4e

~

%7e

  

%1f

O

%4f

  

%7f

space

%20

P

%50

%80

!

%21

Q

%51

  

%81

"

%22

R

%52

%82

#

%23

S

%53

ƒ

%83

$

%24

T

%54

"

%84

%

%25

U

%55

%85

&

%26

V

%56

%86

'

%27

W

%57

%87

(

%28

X

%58

ˆ

%88

)

%29

Y

%59

%89

*

%2a

Z

%5a

Š

%8a

+

%2b

[

%5b

%8b

,

%2c

\

%5c

Œ

%8c

-

%2d

]

%5d

  

%8d

.

%2e

^

%5e

Ž

%8e

/

%2f

_

%5f

  

%8f