Is there a URL validator on .Net?

后端 未结 5 577
失恋的感觉
失恋的感觉 2020-12-28 12:37

Is there a method to validate URLs in .Net, ASP.Net, or ASP.Net MVC?

5条回答
  •  借酒劲吻你
    2020-12-28 13:04

    You can use Uri.IsWellFormedUriString, no need to create your own function for that:

    public static bool IsWellFormedUriString(string uriString, uriKind uriKind);
    

    Where uriKind can be:

    UriKind.RelativeOrAbsolute 
    UriKind.Absolute
    UriKind.Relative
    

    For more info see: http://msdn.microsoft.com/en-us/library/system.uri.iswellformeduristring.aspx

提交回复
热议问题