The current project uses the clickonce technology to deploy the client. The client sometimes needs to transmit some parameters from the server, for programs deployed in clickonce, we can use query strings in the launch URL to achieve this goal. Refer to the article on msdn and soon the code is finished. Okay. Try it. Deployment, from the launch client of the server, everything seems to be normal, and the value of all parameters has been successful.
But before waiting for the check-in code, a test fails. After debugging, it took only half a day to find that it was another plus sign in a parameter value: +. After using httputility. parsequerystring to analyze the query string, the plus sign in the parameter value becomes a space, which does not seem to have been encountered before. Google knows that the original plus signs are reserved in the query string to represent spaces. To pass these reserved characters in the query string, the query string must be encoded.
I modified the server code and added the decode method on the client. I didn't expect the result to be wrong. After checking the msdn help for the httputility. parsequerystring method, we can see that the original method will decode the query string and return the namevaluecollection containing the result.
After half a day, I finally got it done.
Summary:
1) for security reasons, query string must be encode
2) httputility. parsequerystring automatically performs decode.
Happy coding!
~ Crazy