string url= http://www.qiuyun.net/index.aspx?test= 中文;
Response.Write("<a href=\""+url+"\">测试</a>");
如果在后台采用 Request. QueryString ["test"]来获得参数“ 中文 ”的话,可能获得不了,或者
可能获得的是乱码?
解决办法
将上句改成
string url="http://www.qiuyun.net/index.aspx?test="+System.Web.HttpUtility.UrlEncode(" 中文 ");//对 URL 字符串进行编码。
Response.Write("<a href=\""+url+"\">测试</a>");
这时用Request. QueryString ["test"];//就不会有问题了。
解码用 System.Web.HttpUtility.UrlDecode;
在Javascript中编号用encodeURI()方法,解码用decodeURI()方法
另外一个方法是在QueryString中先用它对汉字编码: Server.UrlEncode(汉字).ToString();
例如:http://localhost/test.aspx?lanmu=Server.UrlEncode(汉字).ToString()