Question : valid url in .net
Answered by : muhammad-khizar-hayat
//Try this to validate HTTP URLs (url is the URI you want to test):
// // Checks how well a url validator does against a known list of valid and invalid Urls // The sample urls here are from http://formvalidation.io/validators/uri //
// test
/// in text this only one that most low (17) error
public static bool UrlChecker5(string url) { Uri uriResult; bool result = Uri.TryCreate(url, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); return result; }
// and than (17)
public static bool UrlChecker2(string url) { return Uri.IsWellFormedUriString(url, UriKind.Absolute); }
// if we combine both with like UrlChecker5(url) && UrlChecker2(url)
// error become lowest 15 error
Source : https://stackoverflow.com/questions/7578857/how-to-check-whether-a-string-is-a-valid-http-url | Last Update : Wed, 15 Dec 21