Se serve cambiare lo schema di una url in C#, ad esempio da http a https:

C#

string inputUrl = "http://www.sgart.it/home";

var u = new UriBuilder( inputUrl )
{
    Scheme = Uri.UriSchemeHttps,  // imposto https
    Port = -1 // porta di default per lo schhema
};

string resultUrl = u.ToString();  // ritorna la url con lo schema cambiato -> "https://www.sgart.it/home"

Gli altri schemi possibili sono: SchemeDelimiter, UriSchemeFile, UriSchemeFtp, UriSchemeGopher, UriSchemeHttp, UriSchemeHttps, UriSchemeMailto, UriSchemeNetPipe, UriSchemeNetTcp, UriSchemeNews e UriSchemeNntp.
Tags:
C#235 .NET66
Potrebbe interessarti anche: