【发布时间】:2014-12-09 15:57:40
【问题描述】:
在JavaScript 中我编码了uri 的一部分:
var imageName = "test space in name of image.jpg"
var sentWithAjaxVariable = encodeURIComponent(imageName);
//sentWithAjaxVariable in console is "test%20space%20in%20name%20of%20image.jpeg"
在服务器端,在处理程序中,我想像这样解码这个变量:
var imageName = context.Request.Params["sentWithAjaxVariable"];
var decodedImageName = context.Server.UrlDecode(imageName);
//decodedImageName in watch => "test%20space%20in%20name%20of%20image.jpeg"
为什么不解码?
【问题讨论】:
-
在解码之前检查 imageName,以防你错误地对其进行了两次编码。
标签: javascript c# uri