Changing the scheme of System.Uri

后端 未结 4 1445
逝去的感伤
逝去的感伤 2020-12-30 19:02

I\'m looking for canonical way of changing scheme of a given System.Uri instance with System.UriBuilder without crappy string manipulations and magic constants. Say I have

4条回答
  •  庸人自扰
    2020-12-30 19:23

    Ended up with this one:

    var uriBuilder = new UriBuilder(requestUrl)
    {
        Scheme = Uri.UriSchemeHttps,
        Port = -1 // default port for scheme
    };
    

提交回复
热议问题