手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >asp.net中url字符串编码乱码的原因与解决方法
asp.net中url字符串编码乱码的原因与解决方法
摘要:先看实例复制代码代码如下:functionwebChart(){vart=document.getElementById("txtRecei...

先看实例

复制代码 代码如下:

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出来的编码很正常,都是汉字。

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

但是在后台获取时已经乱码

复制代码 代码如下:

protected void Page_Load(object sender, EventArgs e)

{

Industry = Request.QueryString["_indeustry"].ToString();

InitMap();

getShowMuilt();

}

web.config已经配置为UTF-8 但是还是不行

复制代码 代码如下:

<system.web>

<globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8"

responseEncoding="UTF-8" fileEncoding="UTF-8" />

</system.web>

最终解决方案

复制代码 代码如下:

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;

}

}

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

【asp.net中url字符串编码乱码的原因与解决方法】相关文章:

this connector is disabled错误的解决方法

asp.net开发与web标准的冲突问题的一些常见解决方法

asp.net网站防恶意刷新的Cookies与Session解决方法

asp.net中List的使用方法

asp.net“服务器应用程序不可用” 解决方法

asp.net下百度的编码和解码

asp.net水晶报表参数字段在代码中赋值的方法

asp.net Split分割字符串的方法

asp.net GridView 中增加记录的方法

asp.net 2.0多语言网站解决方法

精品推荐
分类导航