How to use strange characters in a query string
Posted
by peter
on Stack Overflow
See other posts from Stack Overflow
or by peter
Published on 2010-04-14T04:25:00Z
Indexed on
2010/04/14
4:43 UTC
Read the original article
Hit count: 410
I am using silverlight / ASP .NET and C#. What if I want to do this from silverlight for instance,
// I have left out the quotes to show you literally what the characters
// are that I want to use
string password = vtakyoj#"5
string encodedPassword = HttpUtility.UrlEncode(encryptedPassword, Encoding.UTF8);
// encoded password now = vtakyoj%23%225
URI uri = new URI("http://www.url.com/page.aspx@password=vtakyoj%23%225");
HttpPage.Window.Navigate(uri);
If I debug and look at the value of uri it shows up as this (we are still inside the silverlight app),
http://www.url.com?password=vtakyoj%23"5
So the %22 has become a quote for some reason.
If I then debug inside the page.aspx code (which of course is ASP .NET) the value of Request["pasword"] is actually this,
vtakyoj#"5
Which is the original value. How does that work? I would have thought that I would have to go,
HttpUtility.UrlDecode(Request["pswd"], Encoding.UTF8)
To get the original value.
Hope this makes sense?
Thanks.
© Stack Overflow or respective owner