jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Web;
using System.Text.RegularExpressions;
using System.Web.UI.HtmlControls;
using System.IO;
using System.IO.Compression;
using System.Web.UI.WebControls;
using System.Text;
using System.Collections.Generic;
 
namespace HH.WMS.Utils
{
    /// <summary>
    /// WEB请求上下文信息工具类
    /// </summary>
    public partial class ZHttp
    {
        #region 返回指定的服务器变量信息
        /// <summary>
        /// 返回指定的服务器变量信息,如果当前请求或要查找的变量名不存在,返回 null.
        /// </summary>
        /// <param name="name">服务器变量名</param>
        /// <returns>服务器变量信息</returns>
        public static string GetServerValue(string name)
        {
            return HttpContext.Current.Request.ServerVariables[name];
        }
        #endregion
 
        #region 得到当前完整主机头
        /// <summary>
        /// 得到当前完整主机头
        /// </summary>
        /// <returns></returns>
        public static string Host
        {
            get
            {
                return HttpContext.Current.Request.Url.Host;
            }
        }
        #endregion
 
        #region 获取服务器IP
        /// <summary>
        /// 获取服务器IP
        /// </summary>
        public static string LocalIP
        {
            get
            {
                return HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"].ToString();
            }
        }
        #endregion
 
        #region 获取服务器操作系统
        /// <summary>
        /// 获取服务器操作系统
        /// </summary>
        public static string OS
        {
            get
            {
                return Environment.OSVersion.Platform.ToString();
            }
        }
        #endregion
 
        #region 获取服务器域名
        /// <summary>
        /// 获取服务器域名
        /// </summary>
        public static string ServerDomain
        {
            get
            {
                return HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString();
            }
        }
        #endregion
    }
}