Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Problem with swedish characters åäö in webclient
4 replies. Latest Post by deslo on May 15, 2009.
(0)
deslo
Member
31 points
44 Posts
05-08-2009 6:19 AM |
I have a problem with saving data. I use a webclient to communicate with the server, and each time I send something with a å ä or ö in it, that character is converted when it reaches the server. I've tried setting webClient.Encoding but there aren't that many alternatives, and nothing works. How do I solve this?
mbaker3
168 points
71 Posts
05-08-2009 10:54 AM |
Have you tried using HttpUtility.HtmlEncode()? I know thats not exactly what its for but at least the data will be preserved during transfer.
Alternatively it may be worth while to look into the Encoding class (System.text.Encoding). I haven't used it before but converting a compatible format may work.
MarkMonster
Contributor
5124 points
1,038 Posts
05-08-2009 1:15 PM |
That's basically because of the Encoding. Do those characters exist in the encoding used?
SharpGIS
3397 points
611 Posts
05-08-2009 2:27 PM |
Your problem could also be at the server end though...
Usually using UTF8 should work for those characters. Just make sure you use UTF8 in both ends for encoding and decoding.
05-15-2009 4:32 AM |
Could someone post an example of this encoding and decoding? I can't seem to make it work.
Code at client side:
string wUrl = String.Format("caller={0}&proc={1}", wCaller, wProc); wUrl = "http://localhost:50899/slproxy.aspx?" + wUrl; webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webclient_DownloadStringCompleted); webClient.DownloadStringAsync(new Uri(wUrl, UriKind.Absolute));
Code at server side:
Request.ContentEncoding = Encoding.UTF8; string caller = Request.QueryString.Get("caller"); string proc = Request.QueryString.Get("proc");