Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

valid url in .net

//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 by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #valid #url
ADD COMMENT
Topic
Name
5+9 =