核心提示:1、GB2312编码的ASP页传送中文参数代码:a href=default.aspx?username=%=Server.UrlEncode(session('username'))%链接文字/a注...
1、GB2312编码的ASP页传送中文参数代码:
<a href=default.aspx?username=<%=Server.UrlEncode(session("username"))%>>链接文字</a>
注意:ASP中Server.UrlEncode是以GB2312编码进行URL编码的;ANSI等同于中文操作系统的GB2312
2、UTF-8编码的ASP.NET页接收中文参数代码:
string xguser;
NameValueCollection gb2312Requests;
gb2312Requests = HttpUtility.ParseQueryString(Request.Url.Query, Encoding.GetEncoding("GB2312"));
xguser=gb2312Requests["username"];
注意:ASP.NET中在不指定编码的时候,默认是使用UTF-8的编码,自然进行URL反编码的时候用的也是UTF-8编码了。那么,GB2312的URL编码的内容,用UTF-8的URL反编码,那肯定是会不正常的。