How to check that a uri string is valid

后端 未结 5 1718
轻奢々
轻奢々 2020-12-01 08:32

How do you check that a uri string is valid (that you can feed it to the Uri constructor)?

So far I only have the following but for obvious reasons I\'d prefer a les

5条回答
  •  死守一世寂寞
    2020-12-01 09:14

    In my case I just wanted to test the uri, I don't want to slow down the application testing the uri.

    Boolean IsValidUri(String uri){
      return Uri.IsWellFormedUriString(uri, UriKind.Absolute);
    }
    

提交回复
热议问题