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

推荐订阅源

V
Visual Studio Blog
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
腾讯CDC
A
About on SuperTechFans
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
D
DataBreaches.Net
D
Docker
宝玉的分享
宝玉的分享
量子位
Microsoft Azure Blog
Microsoft Azure Blog
Martin Fowler
Martin Fowler
博客园 - 三生石上(FineUI控件)
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
Last Week in AI
Last Week in AI
H
Help Net Security
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence

博客园 - 火龙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;
        }