1

I am passing a query string parameter containing file name.

default.aspx?file=Fame+ adlabs.xml (Fame+ adlabs.xml is the actual file name on server). The file name has "+" & also blank spaces.

When I check for file name from query string as follows:

   var fileName = Request.QueryString["file"];

The variable filename does not have a "+" in it. It reads as "Fame adlabs.xml" & hence I get a file not found exception. I cannot rename the xml files. Can someone please guide me into right direction.

Thanks

Ian
  • 30,182
  • 19
  • 69
  • 107
Robin
  • 283
  • 4
  • 22

2 Answers2

0

You should URL encode into your javascript before sending it :

var name = "Fame+ adlabs.xml";
var url = "default.aspx?file=" + encodeURIComponent(name);

Pay attention that following char won't work : ~!*()'

Deblaton Jean-Philippe
  • 11,188
  • 3
  • 49
  • 66
0

If you are trying to do it at the server in C#:

String FileName = "default.aspx?";

String FullURL = FileName + HttpUtility.UrlEncode("Fame + adlabs.xml");

String Decoded = HttpUtility.UrlDecode(FullURL);
Steve Wellens
  • 20,506
  • 2
  • 28
  • 69