Skip to content

URLs UrlDecoded

September 17, 2012

We had an issue that some urls got UrlDecoded automatically without any apparent reason. We had to find out that some .NET methods implicitly UrlDecode the URLs even if you don’t want that.

The following methods surely decode the URLs, but there might be more:


This method returns a NameValueCollection that contains the QueryString parameters UrlDecoded.
If you want to use this method but don’t want the parameters to be decoded, you can use your own parsing algorithm. You can find one here:


You may expect that the result of new Uri(“url”).ToString() will equal to “url” but that is often not the case

The MSDN documentation and the sample code
also describe that the result of Uri.ToString is not the same as the original string. If you need the original, use the OriginalString property.

Uri uriAddress = new Uri("HTTP://");

// The following outputs "http :// and thin.htm".

Probably you should not use this method in your code, unless you are logging or debugging. Use the OriginalString or AbsoluteUri properties instead.

From → .NET

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: