-1

In JavaScript I encode part of 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"

On server side, in handler I want to decode this variable like this:

var imageName = context.Request.Params["sentWithAjaxVariable"];
var decodedImageName = context.Server.UrlDecode(imageName);
//decodedImageName in watch => "test%20space%20in%20name%20of%20image.jpeg"

why not decode?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Alex
  • 8,908
  • 28
  • 103
  • 157

1 Answers1

0

The method you're looking for is Uri.UnescapeDataString.

It's the respective .NET method for decodeURIComponent in JS.

Luizgrs
  • 4,765
  • 1
  • 22
  • 28