我正在检查任何域名的链接是否链接正常工作。但是当我从localhost调试时,我不能使用特定的域名,例如localhost:xyz/preferences?hl=en
而不是我想要的{{3}我们可以通过替换字符串
var linkWithLocalHost = "http://localhos:234/foo";
var result = // ??? some code that manipulates linkWithLocalHost
// expecting "http://google.co.il/foo" as result
答案 0 :(得分:0)
再一次随机猜测(因为我可能会过度简化要求)。
要操纵网址,请使用相应的课程Uri
和UriBuilder
:
var linkWithLocalHost = "http://localhos:234/foo";
// expecting "http://google.co.il/foo" as result
var builder = new UriBuilder(linkWithLocalHost);
builder.Host = "google.co.il";
builder.Port = 80;
var result = builder.Uri.ToString();
对标题中的问题的回答是:
答案 1 :(得分:0)
您可以使用C:\ Windows \ System32 \ drivers \ etc \ hosts文件。在文件中有说明,说明如何使用它。
例如,我在此文件中附加了一个新行:
127.0.0.1 mywebsite # for stackoverflow question
现在当我将http://mywebsite/
写入浏览器的地址栏时,我会看到通常在撰写http://localhost/
时会看到的页面。