Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用C获取Sharepoint中当前web服务器的名称或IP#_C#_Sharepoint 2010_Webserver - Fatal编程技术网

C# 如何使用C获取Sharepoint中当前web服务器的名称或IP#

C# 如何使用C获取Sharepoint中当前web服务器的名称或IP#,c#,sharepoint-2010,webserver,C#,Sharepoint 2010,Webserver,我正在尝试获取正在访问的SharePoint场中的服务器名或IP。我们有一个负载平衡和两个web前端,因此调试人员很难确定正在访问哪个服务器。 有没有一种方法可以让我们找到正在使用C#代码访问的SharePoint中当前的WFE。我没有找到正确的函数。 请提供任何帮助。System.Environment.MachineName在SharePoint上下文中不能工作吗?使用SPuser类 SPUser currentUser = SPContext.Current.Web.CurrentUser

我正在尝试获取正在访问的SharePoint场中的服务器名或IP。我们有一个负载平衡和两个web前端,因此调试人员很难确定正在访问哪个服务器。 有没有一种方法可以让我们找到正在使用C#代码访问的SharePoint中当前的WFE。我没有找到正确的函数。
请提供任何帮助。

System.Environment.MachineName在SharePoint上下文中不能工作吗?

使用SPuser类

SPUser currentUser = SPContext.Current.Web.CurrentUser;
你可以在这里找到一些有用的信息


您可以使用
Dns.GetHostAddresses
方法()并为主机名传入一个空字符串,该字符串将返回本地主机的ip。使用System.Net添加
然后尝试:

IPAddress[] ips;

ips = Dns.GetHostAddresses("");    

foreach (IPAddress ip in ips)
{
    // Code to display IP address
}