ASP.NET中文乱码问题
2011-07-29 15:38
363 查看
解决ASP.NET中文乱码的方法一般有3种:
1.设置web.config:
1.设置web.config:
< system.web> < globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312" /> < /system.web>
2.前台编码,后台解码:
前台编码:
function GoUrl() { var Name = "中文参数"; location.href = "B.aspx?Name="+escape(Name) ; }
后台解码:
string Name = Server.UrlDecode(Request.QueryString["Name"]);
3.Response.Redirect("test1.aspx?111="+System.Web.HttpUtility.UrlEncode("中华人明共和国")) ; //建议使用最后如果是从其他的页面获取中文参数没有乱码,那就更简单了 string message ="http://localhost/Test/test1.aspx?111="+System.Web.HttpUtility.UrlEncode("中华人明共和国"); http: //你要获取某个页面的返回值的地址" //发送请求 HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(message) ; //接受请求 HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse() ; Stream receiveStream = myHttpWebResponse.GetResponseStream() ; StreamReader readStream = new StreamReader(receiveStream, System.Text.Encoding.GetEncoding("GB2312")) ; //此为要取页面的返回值输出的返回结果 returnValue = readStream.ReadToEnd();
相关文章推荐
- ASP.NET,IE6下URL中文乱码问题
- asp.net(C#)中文乱码问题
- asp.net Cookie值中文乱码问题解决方法
- ASP.NET 导出到EXCEL LINQ适用 自定义列 自定义数据源 解决中文乱码问题 解决方案
- ASP.Net中解决中文乱码问题
- asp.net下载保存对话框中文乱码问题解决
- ASP.NET中文乱码问题解决
- ASP.NET如何解决页面之间传输中文乱码的问题
- Asp.net 2.0 中cookie值为中文时导致的Cookie 值丢失问题和乱码问题的解决
- ASP.NET, IE6下URL中文乱码问题 ASP.NET程序,当URL后缀包含奇数个中文字符
- ASP.NET如何解决页面之间传输中文乱码的问题
- ASP.NET中url传递中文的解决方案,传递参数为汉字时出现乱码等问题
- 解决C#ASP.NET下载出现中文文件名乱码的问题
- C# asp.net页面通过URL参数传值中文乱码问题解决办法
- asp.net 解决中文乱码问题
- asp.net Request.QueryString中文乱码问题
- asp.net(C#)中文乱码问题
- asp.net 中文乱码问题
- 解决asp.net core在输出中文时乱码的问题
- asp.net中文cookie的乱码问题