Click here to Skip to main content
15,921,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to encode spaces as "%20" in a query string. I found som MSDN help on this here: http://msdn.microsoft.com/en-us/library/zttxte6w.aspx[^]

When I call this method it appears to do absolutely nothing to the string I pass in - i.e. the one I get back still contains spaces.

I think I am missing something obvious here or possibly barking up completely the wrong tree. Any help would be very much appreciated.


Kind wishes, Patrick
Posted

When I try it:
C#
litWelcome.Text = "Welcome back " + User.UserName + Server.UrlEncode(" ASP.NET Examples");
I get the message:
Welcome back OriginalGriff+ASP.NET+Examples
Which is what I would expect. UrlEncode does not encode spaces as %20 - it replaces them with "+"
 
Share this answer
 
As the link says - ASP.NET Examples will be encoded to ASP.NET+Examples
 
Share this answer
 
Hi,

Thanks for those replies. Encoding with '+' would be absolutely fine but I get back a string that still contains the spaces. Mmm ... very strange.

- Patrick
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900