开发者

Given a Uri value how can one check whether it refers the local machine?

How can o开发者_Python百科ne check that an absolute Uri refers the local machine?

Currently I am using this simple procedure:

var isLocalMachine = uri.IsLoopback || string.Equals(uri.HostName, Environment.MachineName, StringComparison.OrdinalIgnoreCase);

But this is not good enough, because:

  • the optional domain name is left unattended.
  • the same machine may have several different DNS names
  • the host name may be an IP address, which is not handled at all

If it is possible, I would like to have a procedure, which does not generate any network queries.

Thanks.


Have a look at this stackoverflow-qestion, especially Eric Rosenberger's answer: Method to determine if path string is local or remote machine

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜