C# JS URL 中文傳參出現亂碼的解決方法

Hellen.Li發表於2013-08-26

在傳參是先編碼在傳輸,接受時先編碼,在接收。

string mm=Server.URLEncode(你);

Response.Redirect(index.aspx?mm=+mm);

然後在接收頁解碼:

string mm = Server.URLDecode(Requext.querystring(mm));

js:

傳參:用encodeURI("url引數")將url編碼

收參:用decodeURI("接收到的值")解碼

 

js傳遞引數,c# 接收引數 :

escape(s)

Server.URLDecode(Requext.querystring(s));

如果是url重寫後的中文引數:

escape(escape(s))  這個是本人嘗試了很多次之後得出來的

Server.URLDecode(Requext.querystring(s));

 

相關文章