读书人

如何Response.Redirect传出来的中文值

发布时间: 2012-02-22 19:36:54 作者: rapoo

怎么Response.Redirect传出来的中文值总是变成乱码~~~!
CS代码如下:

protected void Page_Load(object sender, EventArgs e)
{
string types = "医药类 ";
if (Request.QueryString[ "A "] == null)
{
Response.Redirect(Request.RawUrl + "?A= " + types);
}
}

我已经试过下面方法:
方法一:HttpUtility.UrlEncode(types)

方法二:在ASPX文件中加入 <meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">

方法三:在Web.Config里加入 <globalization fileEncoding= "gb2312 " requestEncoding= "gb2312 " responseEncoding= "gb2312 "/>

这些方法全无效果,

我在这IE地址栏显示中文是想便于搜索引擎搜索

接收的的乱码值并没有问题

我最终想要的效果是最后显示在地址栏上的是 xxx.aspx?A=医药类

[解决办法]
用代码写好像不行,变个法子,试试这个:

Response.Redirect(Request.RawUrl + "?A= " +Server.UrlEncode( types));
--改为
Response.Write( " <script> self.location.href= 'Default.aspx?id=中国 '; </script> ");
[解决办法]
中文参数 C#一般接收不到

除非用JS接收

读书人网 >asp.net

热点推荐