源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

asp.net中url字符串编码乱码的原因与解决方法

  • 时间:2020-05-27 16:29 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:asp.net中url字符串编码乱码的原因与解决方法
先看实例
[u]复制代码[/u] 代码如下:
 function webChart() {             var t = document.getElementById("txtReceive");             if (t.value == null || t.value == "") {                 alert("请先进行查询");             }             else {                 alert(t.value);                 document.getElementById("center-iframe").src = "map/industryMap.aspx?_indeustry=" + t.value; }}
这个时候alert出来的编码很正常,都是汉字。 [img]http://files.jb51.net/file_images/article/201308/201381495527257.jpg[/img] 但是在后台获取时已经乱码
[u]复制代码[/u] 代码如下:
        protected void Page_Load(object sender, EventArgs e)         {             Industry = Request.QueryString["_indeustry"].ToString();             InitMap();             getShowMuilt();         }
web.config已经配置为UTF-8 但是还是不行
[u]复制代码[/u] 代码如下:
<system.web>     <globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8"                    responseEncoding="UTF-8" fileEncoding="UTF-8" />   </system.web>
最终解决方案
[u]复制代码[/u] 代码如下:
 function webChart() {             var t = document.getElementById("txtReceive");             if (t.value == null || t.value == "") {                 alert("请先进行查询");             }             else {                 var url = encodeURI("map/industryMap.aspx?_indeustry=" + t.value);                 alert(url);                 document.getElementById("center-iframe").src = url; } }
[img]http://files.jb51.net/file_images/article/201308/201381495841243.jpg[/img]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部