C#, Is there a better way to verify URL formatting than IsWellFormedUriString?

后端 未结 4 1894
夕颜
夕颜 2021-02-08 05:09

Is there a better/more accurate/stricter method/way to find out if a URL is properly formatted?

Using:

bool IsGoodUrl = Uri.IsWellForm         


        
4条回答
  •  梦谈多话
    2021-02-08 05:18

    This Code works fine for me to check a Textbox have valid URL format

    if((!string.IsNullOrEmpty(TXBProductionURL.Text)) && (Uri.IsWellFormedUriString(TXBProductionURL.Text, UriKind.Absolute)))
    {
         // assign as valid URL                
         isValidProductionURL = true; 
    
    }
    

提交回复
热议问题