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
var uri = new Uri("http://localhost/hello")
and I need to change it to 'https'. My issue is in limited UriBuilder
ctors and Uri.Port
defaulting to 80 (should we change it to 443? hardcoding?). The code must respect all Uri
properties such as possible basic auth credentials, query string, etc.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…