Use space value in QueryString

Hello all,

Today we will talk on query string value. We are using query string to pass value from one page to another page. Some time we need to pass value as string and string has some space value too. That time we are not getting exact value on another page because query sting is not pass correctly.

For e.g.

some text

OUTPUT :
str = test

To solve this problem we have to encode url. URL does not contain spaces.
There are two possible solution of this problem one is remove space from url another one is encode/decode url.

StringBuilder sb = new StringBuilder();
string strValue = "test value";
sb.Append("" + some text + "");
sb.Append("");

another way is

StringBuilder sb = new StringBuilder();
string strValue = "test value";
sb.Append("" + some text + "");
sb.Append("");

OUTPUT :
str = test value

HttpUtility is referenced to System.Web class. I prefer to use HttpUtility because it will eliminate space and other characters too.