I’m trying to determine whether or not a given string is a valid url or not. And in my scenario, the url can have parameters:
- www.example.com -> OK
- example.test -> OK (although there’s no .test TLD)
- example.com/page.htm?abc=123 -> OK
- xxx/xxx.jpg -> Not OK
- xxx -> Not OK
I’ve tried the Uri.TryCreate method, Uri.TryCreate(url, UriKind.Absolute, null);, but it accepts pretty much anything that has an http:// prefix, i.e. “http://xxx/” is OK.
I can’t use an HTTP request to check/ping the site for performance reasons.
Any suggestions?
http://xxxOK? See, for example, to. (Your browser may choke on that; you may need to add a trailing period)http://xxx/