WCF URI仅适用于localhost

时间:2011-03-22 20:35:18

标签: c# wcf

创建服务主机后,当我使用Internet Explorer时,我无法打开“http:// myuri:8000 / ServiceModelSamples / Service”页面。

  Uri baseAddress = new Uri("http://myuri:8000/ServiceModelSamples/Service");

  // Step 2 of the hosting procedure: Create ServiceHost
  ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
  // rest of the below code is from calculator MSDN sample

只有当我使用localhost而不是“myuri”时它才有效。有人可以告诉你还需要什么吗?

编辑:myri实际上是我的PC名称。我也尝试在我的电脑上使用IP地址。 Internet Explorer可以从我的框中打开URL,但是当我从其他框中打开URL时它会失败(例如,我尝试打开的URL是http://111.251.164.20:8000/ServiceModelSamples/Service

2 个答案:

答案 0 :(得分:5)

Eh ...... myuri只是一个例子,一个占位符。不是你应该按字面意思使用的东西。

答案 1 :(得分:2)

如果你真的想使用myuri,你需要在hosts.ini文件中添加一条记录。

赞:127.0.0.1 myuri localhost

相关问题