2013-01-31 39 views
0

當我嘗試發送德文字符到服務器時,正確的instad我得到了一些奇怪的字符。我用MVC2和jQuery 1.8.1IE geJSON不編碼德文字符

我嘗試發送這樣

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

      }); 
     } 

值我通過是單詞「Prüfung」

,並在服務器端我收到「Prfung」 ,Internet Explorer和Firefox上都存在這個問題,上一切都很好。

+0

你嘗試UTF8加密/解碼你的價值? – ses3ion

回答

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 
+0

非常感謝。 – kosnkov

+0

@kosnkov很高興幫助 – Johan