123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- namespace WebAPIBase.Utils
- {
- public class RequestHelper
- {
- /// <summary>
- /// 是否为远程服务器,DEBUG用
- /// </summary>
- public static bool IsRemote
- {
- get
- {
- string address = RequestHelper.GetServerIp();
- bool a = !address.Contains("192.168.") && !address.Contains("127.0.") && !address.Contains("2.0.");
- return a;
- }
- }
- static string serverIp;
- public static string GetServerIp()
- {
- if (string.IsNullOrEmpty(serverIp))
- {
- System.Net.IPAddress[] addressList = Dns.GetHostAddresses(Dns.GetHostName());
- string address = "";
- foreach (System.Net.IPAddress a in addressList)
- {
- if (a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
- {
- address = a.ToString();
- break;
- }
- }
- serverIp = address;
- }
- return serverIp;
- }
- }
- }
|