ASP 傳中文參數到 ASP.NET

由 ASP(Big5) 傳含中文參數的值給 ASP.NET(UTF-8)

老是忘了,稍微紀錄一下

ASP (big5) 傳含中文的參數值到 ASP.NET (UTF-8)

 

傳送方 ASP (big5 編碼)


<a href="sample.aspx?arg=<%=Server.URLEncode("中文參數") %>">to ASP.NET</a>

 

接收端 ASP.NET (UTF-8)


//using System.Collections.Specialized;
 string query = HttpUtility.UrlDecode(Request.Url.Query, System.Text.Encoding.GetEncoding("big5"));
 NameValueCollection args = HttpUtility.ParseQueryString(query);
Response.Write(args["arg"].ToString());

 

參考資料:

http://blog.darkthread.net/post-2010-01-06-parsequerystring.aspx

http://welkingunther.pixnet.net/blog/post/29957179-(asp.net)%E7%B6%B2%E5%9D%80%E5%82%B3%E4%B8%AD%E6%96%87%E5%8F%83%E6%95%B8%E6%9C%83%E4%BA%82%E7%A2%BC

http://pikachumk2.pixnet.net/blog/post/22762234-%E5%A6%82%E4%BD%95%E8%AE%93asp.net%E7%B6%B2%E9%A0%81%E6%AD%A3%E7%A2%BA%E6%8E%A5%E6%94%B6%E7%94%B1vbcript%E5%8F%8Aasp%E6%89%80%E5%82%B3%E9%80%81