Encode query string in asp.net


code on first page from where you are using querysting

String strVal1 = "My first value"

String strVal2= "My Second Value"
String strUrl= String.Format("default2.aspx?{0}&{1}", Server.UrlEncode(strVal1), Server.UrlEncode(strVal2))

Response.Redirect(strUrl)

code on the second page to get querystring value

String strQueryVal1=Server.UrlDecode(Request.QueryString"strVal1"))

String strQueryVal2= Server.UrlDecode(Request.QueryString("strVal2"))

This will be very helpfull when you have some string value like " Home & Office". In this exaple if you use simply query string to pass the value then you will get the value in output as "Home Office".
try it. :)