web analytics

How to Validate URL in C#

Options

codeling 1599 - 6654
@2017-01-03 20:51:47

The method Uri.TryCreate can be used to check if string is a valid URL or not in C#.

Uri newUrl = null;

if (!string.IsNullOrEmpty(oldUrl) && Uri.TryCreate(oldUrl, UriKind.Absolute, out newUrl)

{

    //valid URL

}

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com