求教:如何在类里访问Cookies? 我想在一个公共类的方法中访问Cookies,可是response对象只在继承于 System.Web.UI.Page 的类里才能应用。请问如何在公共类里访问到Cookies? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 HttpContext.Current.Request.CookiesHttpContext.Current.Response.Cookies HttpCookie cookie1=HttpContext.Current.Request.Cookies["UserInfo"];string name=cookie1.Values["UserName"].ToString(); 谢谢大家。还请问“tomsonyang(甲壳虫)”:如何传入page参数?希望侧举个例子。谢谢 传个HttpContext.Current,然后就可以调用response和request进行操作了class c{ HttpContext mContext; public c(HttpContext context) { mContext=context } ...以后就可以使用mContext访问Response和Request了 当然也可以操作cookie了} c myc=new c(HttpContext.Current);//构造c时传个HttpContext进去 asp.net 在不停刷新 sqlite数据库时不进的出现Unable to open the database file错误 取不到GridVeiw中绑定的DropDownList的值 DIV有什么用 如何按显示方式更换模版 关于iis虚拟路径的问题 xml新手,求教.net下取节点问题 请教自动自动跳转问题 看了半天也不明白,到底 ASP.NET 模拟 有什么用? 关于String.IndexOf asp.net的blog和论坛大家用什么? 誰有發郵件的例子 散分。。。(100分)在線等。。。。
HttpContext.Current.Response.Cookies
string name=cookie1.Values["UserName"].ToString();
还请问“tomsonyang(甲壳虫)”:
如何传入page参数?希望侧举个例子。
谢谢
class c
{
HttpContext mContext;
public c(HttpContext context)
{
mContext=context
}
...以后就可以使用mContext访问Response和Request了 当然也可以操作cookie了
}