url does not decode properly with request[] in C#
https://stackoverflow.com/questions/642460
Question
I have an object like this:
public class adapterContext {
public HttpRequest Request;
}
adapterContext ac = new adapterContext();
ac.Response = context.Response;
I pass this object to my functions and use ac.Request[""] to get my url variables. However this somehow does not translate national/special characters correct. When I use f.ex this as part of the URL: prospectName=Tester+%e6+%f8+%e5
I get "Tester ? ? ?"
From the debugger I get: ac.Request["prospectName"][7] 65533 '�' char
Anyone have any idea how I should fix this?
Solution
there's a nice function, you should take care of: HttpUtility.UrlDecode(string, Encoding) ... otherwise you need to adjust the globalization setting in your web.config (requestEncoding, responseEncoding ...)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow