【问题标题】:Can't find Path when not at LocalHost不在 LocalHost 时找不到路径
【发布时间】:2013-10-18 07:20:05
【问题描述】:

我正在使用 WCF。当我使用 localhost 启动应用程序时,我可以得到这个路径:

string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\Version.txt");

我的网址是:

http://localhost:4426/MyService.svc

但是当我将“ServiceHost Uri”更改为我的计算机主机名时,WCF 找不到 de 路径!

http://myhost:4426/MyService.svc

发生了什么事?

【问题讨论】:

    标签: .net wcf localhost


    【解决方案1】:

    你能ping通“myhost”吗?如果没有,您可以在主机文件中添加“myhost”,以便在请求“myhost”时知道要解析哪个 ip。

    【讨论】:

    • 但它必须用你的PC公共IP解决,而LocalHost没有,它需要在网络上走得更远,因此可能会导致权限或限制问题。它会产生错误吗?如果是,您可以发布错误消息和堆栈跟踪吗?
    猜你喜欢
    • 2014-01-27
    • 1970-01-01
    • 1970-01-01
    • 2020-05-18
    • 2013-08-09
    • 2013-05-27
    • 2013-02-26
    • 2018-05-23
    相关资源
    最近更新 更多