• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

url decode

Hi,

How can I decode url using vb.net or c# or asp.net, the example is as below:


encoded:
http://en.wikipedia.org/wiki/simple:car

Decoded by browser:
http://simple.wikipedia.org/wiki/Car
Other scenario are characters like %6C in url.

I need clean url so I can use with DownloadString of webClient to scrape data.

Thank you
0
mkk39
Asked:
mkk39
1 Solution
 
mrichmonCommented:
Well basic decoding is done via the HttpServerUtility.UrlDecode method


http://msdn.microsoft.com/en-us/library/6196h3wt.aspx

But that doesn't handle the URL conversion that wikipedia is doing....
0
 
mkk39Author Commented:
Thanks for reply

I already tried it but it is not working with example I have shown, please help me to solve issue with my example too

Thank you
0
 
mrichmonCommented:
Your example is not encoded therefore cannot be decoded.  It is being converted by wikipedia.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mkk39Author Commented:
So, how can I handle it to use with DownloadString ? or any other solution?
0
 
mkk39Author Commented:
Is there any other trick used by wiki, like here in example usage of colon. Can u please tell me if there are others too

Thank you
0
 
Algol36Commented:
WebClient wc = new WebClient();
            wc.Headers.Add("User-Agent: Mozilla/4.0 (compatible; MSIE 8.0)");
            string s = wc.DownloadString("http://en.wikipedia.org/wiki/simple:car");
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now