Charlie
Charlie

Reputation: 4895

Unable to find illegal Characters in Path

I am unable to find illegal characters in

www.rightmove.co.uk/propertyMedia/redirect.html?propertyId=47772832&contentId=778055923&index=0

This is the URL I took from my debugger.

I use the above URL in this method of WebClient

string document = w.DownloadString(url);

This throws an exception:

Argument Exception :Illegal Characters in path

The URL works fine when I copy it into Chrome directly. Any idea what the problem could be?

Upvotes: 2

Views: 889

Answers (1)

denys-vega
denys-vega

Reputation: 3697

I think the issue is because the protocol is missing (http or https)

Use Uri.IsWellFormedUriString to check if an Uri is valid.

False:

Uri.IsWellFormedUriString("www.rightmove.co.uk/propertyMedia/redirect.html?propertyId=47772832&contentId=778055923&index=0",UriKind.Absolute);

True:

Uri.IsWellFormedUriString("http://www.rightmove.co.uk/propertyMedia/redirect.html?propertyId=47772832&contentId=778055923&index=0",UriKind.Absolute);

Upvotes: 4

Related Questions