IE geJSON不编码德语字符

时间:2013-01-31 11:55:26

标签: jquery html asp.net-mvc internet-explorer

当我尝试将德语字符发送到服务器时,正确的instad我得到了一些字符。我使用mvc2和jquery 1.8.1

我尝试发送这种方式

function changeFileName(value, selection, oppId, idForOkImg) {
            alert(value);
            $.getJSON('<%= Url.ActionOrm("ChangeTypeOfFile", "Opportunity")%>?fileName=' + value , null , function () {
                displayUploadedFiles(idForOkImg);

            });
        }
我通过的值是“Prüfung”这个词

并且在服务器端我收到“Pr fung”,这个问题存在于Internet Explorer和Firefox上,在chrom上都很好。

1 个答案:

答案 0 :(得分:1)

将其编码为:

$.getJSON('<%= Url.ActionOrm("ChangeTypeOfFile", "Opportunity")%>', 
{ fileName: encodeURIComponent(value) }, 
function () {
    displayUploadedFiles(idForOkImg);
});

在c#中:

string fileName = HttpContext.Current.Request["fileName"]; //Pr%C3%BCfung
fileName = HttpUtility.UrlDecode(fileName); //Prüfung