国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net中url字符串編碼亂碼的原因與解決方法

2020-01-17 23:47:39
字體:
來源:轉載
供稿:網友

先看實例

復制代碼 代碼如下:

 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出來的編碼很正常,都是漢字。

但是在后臺獲取時已經亂碼

復制代碼 代碼如下:

        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;
}
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湖北省| 纳雍县| 赣榆县| 翼城县| 宁强县| 那坡县| 亳州市| 班戈县| 虞城县| 恭城| 金川县| 鹤峰县| 康乐县| 黄陵县| 迁安市| 芒康县| 宁海县| 铁岭县| 甘孜| 靖安县| 高邑县| 嵩明县| 大安市| 凤翔县| 河北省| 金门县| 清远市| 彝良县| 昆山市| 嘉善县| 迁安市| 仁怀市| 仁化县| 阳东县| 安吉县| 伊吾县| 闸北区| 新绛县| 乳山市| 甘德县| 容城县|