在asp.net中读取Cookie值

编程入门 行业动态 更新时间:2024-10-27 19:23:10
本文介绍了在asp中读取Cookie值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨Techies, 我的应用程序中有一个要求,我需要从其他应用程序创建的浏览器中读取Cookie.我无法读取Cookie值. Cookie是会话cookie,当浏览器丢失会话时,该cookie将会过期.我使用以下代码在浏览器中读取了所有cookie.但是,我找不到想要的Cookie.

Hi Techies, I have a requirement in my application that i need to read a cookie from the browser which is created by the other application. I am not able to read the cookie value. The cookie is a session cookie which will expires when browser lost the session. I used the below code to read all the cookies in browser. But, i couldn''t get the cookie that i am looking for.

Request.ServerVariables["HTTP_COOKIE"];

请帮助我通过.NET应用程序读取Cookie值. 问候, Vijay Kumar E,

Please help me in reading the cookie value through .NET application. Regards, Vijay Kumar E,

推荐答案

您可以使用以下函数获取Cookie值. You can get the cookie value using following function. getCookieValue("Cookie_key"); public static string getCookieValue(string strKey) { if (HttpContext.Current.Response.Cookies[strKey] != null && HttpContext.Current.Response.Cookies[strKey].Value + "" != "") { return HttpContext.Current.Response.Cookies[strKey].Value; } else if (HttpContext.Current.Request.Cookies[strKey] != null) { HttpContext.Current.Response.Cookies[strKey].Value = HttpContext.Current.Request.Cookies[strKey].Value; return HttpContext.Current.Request.Cookies[strKey].Value; } else { return ""; } }

更多推荐

在asp.net中读取Cookie值

本文发布于:2023-11-09 22:37:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573622.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:asp   net   Cookie

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!