惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
WordPress大学
WordPress大学
小众软件
小众软件
云风的 BLOG
云风的 BLOG
IT之家
IT之家
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
宝玉的分享
宝玉的分享
博客园 - Franky
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
D
Docker
博客园 - 聂微东
C
Check Point Blog
H
Help Net Security

博客园 - 火龙sky

ASP.NET Ajax发布时异步刷新失效的问题解决方法 关于Tomcat虚拟主机域名的设置--设置本地主机域名 Sql Server 中一个非常强大的日期格式化函数 针对sql 2005优化的高性能分页存储过程 大型网站架构设计 在ASP.NET中记录错误日志(使用Global.asax) 一个完美的的项目经理 CuteEditor6.0 使用 CE寻找游戏基址+偏移 VirtualAllocEx函数 了解游戏外挂 c#做外挂 step by step(更新至step3:注入) Sql-Server应用程序的高级Sql注入 教程: 汇编语言的准备知识-给初次接触汇编者4 教程: 汇编语言的准备知识-给初次接触汇编者3 教程: 汇编语言的准备知识-给初次接触汇编者2 汇编语言的准备知识--给初次接触汇编者 1 邮件简单发送 设置HtmlMeta 值
GetIP cookies
火龙sky · 2008-10-23 · via 博客园 - 火龙sky

        #region 设置Cookies值                        SetCookies(string cookiesname, string cookiesvalue, int Expirestime)
        /// <summary>
        /// 设置Cookies值
        /// </summary>
        /// <param name="cookiesname">名称</param>
        /// <param name="cookiesvalue">内容</param>
        /// <param name="Expirestime">过期时间,0表示默认过期时间</param>
        public static void SetCookies(string cookiesname, string cookiesvalue, int Expirestime)
        {
            HttpContext.Current.Response.Cookies[cookiesname].Value = cookiesvalue;
            if (Expirestime != 0)
                HttpContext.Current.Response.Cookies[cookiesname].Expires = DateTime.Now.AddDays(Expirestime);
        }
        #endregion

        #region 取Cookies值                          string GetCookies(string cookiesname)
        public static string GetCookies(string cookiesname)
        {
            string obj = string.Empty;
            try
            {
                return HttpContext.Current.Request.Cookies[cookiesname].Value;
            }
            catch
            {
                return obj;
            }
        }
        #endregion

        public static string GetIPAddress()
        {

            string user_IP = string.Empty;
            if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
            {
                if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
                {
                    user_IP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                }
                else
                {
                    user_IP = System.Web.HttpContext.Current.Request.UserHostAddress;
                }
            }
            else
            {
                user_IP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
            }
            return user_IP;
        }