Reputation: 91
All
I have the the following lines of code... (.net 3.5)
string URL = "http://api.linkedin.com/v1/people/url=http%3a%2f%2fuk.linkedin.com%2fpub%2fjulian-welby-everard%2f0%2fb97%2f416";
UriBuilder uri = new UriBuilder(URL);
this returns a URL in the URI object of http://api.linkedin.com/v1/people/url=http://uk.linkedin.com/pub/julian-welby-everard/0/b97/416 which as been decoded, I do not what this to happen
so I tried to encoded the data twice giving
string URL = "http://api.linkedin.com/v1/people/url=http%253a%252f%252fuk.linkedin.com%252fpub%252fjulian-welby-everard%252f0%252fb97%252f416";
UriBuilder uri = new UriBuilder(URL);
this now returns the URL as follows http://api.linkedin.com/v1/people/url=http%253a%252f%252fuk.linkedin.com%252fpub%252fjulian-welby-everard%252f0%252fb97%252f416 note that it has not decoded anything this time, i was hoping that it would decode just like the first attempt but as this had been double encoded it would return the string in the correct format.
So the question is as follows, I can I stop the URI object from decoding the supplied URL so I can pass the correct data accross to the HttpWebRequest.
Julian
Upvotes: 1
Views: 5352
Reputation: 9950
I believe you are looking for HttpUtility.UrlEncode("http://www.google.com/") which returns http%3a%2f%2fwww.google.com%2f.
Upvotes: 1