简体   繁体   English

C#将方案添加到URI

[英]C# add scheme to URI

I'm trying to add the HTTP Protocol to this URI "example:8888" 我正在尝试将HTTP协议添加到此URI“ example:8888”

What I've done : 我所做的:

var uriBuilder = new UriBuilder("example:8888")
{
  Scheme = Uri.UriSchemeHttp,
};
var uri = uriBuilder.Uri;

The Output is 输出是

http:0.0.34.184

What I'm doing wrong :S ? 我在做什么错了:S?

Your string is being parsed as the URL path, not a hostname. 您的字符串被解析为URL路径,而不是主机名。
To force it to parse as a hostname, you need to add a scheme to the string. 要强制将其解析为主机名,您需要向字符串添加方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM