ApplicationClientHelper.cs 597 B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web;
  6. namespace EMIS.Utility
  7. {
  8. public class ApplicationClientHelper
  9. {
  10. public static string GetIP()
  11. {
  12. if (HttpContext.Current != null)
  13. {
  14. return HttpContext.Current.Request.UserHostAddress;
  15. }
  16. else
  17. {
  18. System.Net.IPHostEntry myEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
  19. return myEntry.AddressList[0].ToString();
  20. }
  21. }
  22. }
  23. }