【问题标题】:After UrlDecode nothing changes [duplicate]在 UrlDecode 之后没有任何变化[重复]
【发布时间】: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


【解决方案1】:

您要查找的方法是Uri.UnescapeDataString

这是 JS 中 decodeURIComponent 各自的 .NET 方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-06
    • 2021-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多