cs中不能直接写session的问题的解决方法!
2008-01-26 18:15
896 查看
protected override void OnLoad(EventArgs e)
{
HttpCookie MyCookie = System.Web.HttpContext.Current.Request.Cookies["UserId"];
if (MyCookie != null)
{
string UserId = DBConvert.ToString(MyCookie.Value);
if (Session["BBSEntity"] != null)
{
if (UserId != DBConvert.ToString(((BBS_InfoEntity)Session["BBSEntity"]).UserId))
{
Session["BBSEntity"] = null;
getUserInfo(UserId);
}
}
else
{
getUserInfo(UserId);
//给BBSEntity赋值游客记录
}
}
else
{
Session["BBSEntity"] = null;
MyCookie = new HttpCookie("UserId", "100");
//本机未设置域名访问,不可测试,需要发布后才能测试,更改config文件
MyCookie.Domain = ConfigurationManager.AppSettings["domain"].ToString();
//MyCookie.Expires = DateTime.Now.AddYears(1);
System.Web.HttpContext.Current.Response.Cookies.Set(MyCookie);
string UserId = DBConvert.ToString(MyCookie.Value);
getUserInfo(UserId);
}
getCacheValue();
BBSEntity = (BBS_InfoEntity)(Session["BBSEntity"]);
CommEntity = (CommonEntity)(HttpRuntime.Cache["CommEntity"]);
base.OnLoad(e);
}
{
HttpCookie MyCookie = System.Web.HttpContext.Current.Request.Cookies["UserId"];
if (MyCookie != null)
{
string UserId = DBConvert.ToString(MyCookie.Value);
if (Session["BBSEntity"] != null)
{
if (UserId != DBConvert.ToString(((BBS_InfoEntity)Session["BBSEntity"]).UserId))
{
Session["BBSEntity"] = null;
getUserInfo(UserId);
}
}
else
{
getUserInfo(UserId);
//给BBSEntity赋值游客记录
}
}
else
{
Session["BBSEntity"] = null;
MyCookie = new HttpCookie("UserId", "100");
//本机未设置域名访问,不可测试,需要发布后才能测试,更改config文件
MyCookie.Domain = ConfigurationManager.AppSettings["domain"].ToString();
//MyCookie.Expires = DateTime.Now.AddYears(1);
System.Web.HttpContext.Current.Response.Cookies.Set(MyCookie);
string UserId = DBConvert.ToString(MyCookie.Value);
getUserInfo(UserId);
}
getCacheValue();
BBSEntity = (BBS_InfoEntity)(Session["BBSEntity"]);
CommEntity = (CommonEntity)(HttpRuntime.Cache["CommEntity"]);
base.OnLoad(e);
}
相关文章推荐
- win8系统 ps不能直接拖入图片的问题!解决方法
- cs文件中不能继承System.Web.UI.Page问题的解决方法
- 关于realarm210 realarmTest.apk不能直接安装问题解决方法
- 【问题解决】Safari不能保存session的处理方法
- Apache + Tomcat 负载均衡集群配置问题 session不能复制(解决方法)
- FlexContext.getFlexSession()在servlet的doPost方法中不能用的问题解决
- cs文件中不能继承System.Web.UI.Page问题的解决方法
- 【已解决】本地测试时,MUI的AJAX方法不能获取数据的问题。
- qt 在win8 win10下不能拖拽文件到程序的问题 终于找到答案了 因为把程序的权限设置太高了.解决方法,降低运行权限
- 解决php中Cannot send session cache limiter 的问题的方法
- Nginx安装BugFree后/site/login 不能访问的问题解决方法--Nginx启用rewrite
- 从 CCS 1.1 升级到 CS 2.0 所遇到的问题和部分解决方法
- 万网虚拟机不能使用smtp的问题解决方法
- 1 用最原始的方法解决乱码问题---直接手动转码
- Ubuntu 14.04 不能使用 MTK Flash Tools 问题解决方法
- 解决session关闭时再调用对象方法时报session已关闭问题
- qt designer “property editor”编辑时键盘不能使用问题解决方法
- Asp.net在ashx文件中处理Session问题解决方法
- Ubuntu在VirtualBox中不能全屏的问题解决方法(可与XP复制粘贴)
- ThinkPHP框架实现session跨域问题的解决方法