现在的位置: 首页 > 综合 > 正文

URL 中文传参数

2013年03月26日 ⁄ 综合 ⁄ 共 431字 ⁄ 字号 评论关闭

1.设置web.config文件。
<system.web>
......
<globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312" />
......
</system.web>
 
或者:
aspx文件中:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

2.传递中文之前,将要传递的中文参数进行编码,在接收时再进行解码。
>> 进行传递
string Name = "中文参数";
Response.Redirect("B.aspx?Name="+Server.UrlEncode(Name));

>> 进行接收
string Name = Request.QueryString["Name"];
Response.Write(Server.UrlDecode(Name)); 

抱歉!评论已关闭.