Reputation: 2611
I'm using the WebClient class to download files from a web site and have a couple of questions.
When the URIs have HTML characters in the URI path (eg http://foo.com/path1&
path2.pdf) I get 404 (not found) errors. How can I prevent this? I thought HTML characters were safe?
When the URIs represent a directory (eg http://foo.com/path) I get 403 (forbidden) errors. I understand why this is occuring but how can I test my URI to see if it represents a directory with no index page.
Upvotes: 1
Views: 1393
Reputation: 56448
foo.com/page?foo=1&bar=2
. If you have special characters that must go in URLs, like ampersands that are not part of the query portion of the URL, you'll want to URL encode them. Use HttpUtility.UrlEncodeUpvotes: 3