How to remove the port number from a url string

前端 未结 8 616
清酒与你
清酒与你 2021-02-02 04:57

I have the following code snippet:

string tmp = String.Format(\"

        
8条回答
  •  情歌与酒
    2021-02-02 05:42

    You can use the UriBuilder and set the value of the port to -1

    and the code will be like this:

    Uri tmpUri = new Uri("http://LocalHost:443/Account/Index");
    UriBuilder builder = new UriBuilder(tmpUri);
    builder.Port = -1;
    Uri newUri = builder.Uri;
    

提交回复
热议问题