You are on page 1of 1

We are passing some parameters (Server.

UrlEncode) from one page to another via the


url QueryString. However, in a case when there is a +, it disappeared, after
Server.UrlDecode. Using Server.HtmlEncode and Server.HtmlDecode produce the same
result.

For eg, <t1> +2 becomes <t1> 2

Page 1:
string msg = "<t1> +2";
string encoded = Server.UrlEncode(Server.HtmlEncode(msg));
StringBuilder url = new StringBuilder();
url.Append("Default8a.aspx?P1=");
url.Append(encoded);
Response.Redirect(url.ToString(), true);

Page 2:
string p1 =
Server.UrlDecode(Server.HtmlDecode(Request.QueryString["P1"])).ToString();

How would you preserve the + sign?

Thanks,

You might also like