首页 C#前端开发当Session失效时,提示用户重新登录。分析

C#前端开发当Session失效时,提示用户重新登录。分析

举报
开通vip

C#前端开发当Session失效时,提示用户重新登录。分析当Session失效时,提示用户重新登录。1、增加一个父类.比如叫BasePageBasePage继承System.Web.UI.Page你的页面继承BasePage然后在BasePage中overrideOnLoad函数.加入判断Session是否失效,每个继承BasePage的页面加载时都会进去OnLoad进行检测了icrud_tables/5how_housekaspxApp_Code/BaseHandlenc弋crudtablesshowbouGe▼卢Page^Loac-usingSystem:...

C#前端开发当Session失效时,提示用户重新登录。分析
当Session失效时,提示用户重新登录。1、增加一个父类.比如叫BasePageBasePage继承System.Web.UI.Page你的页面继承BasePage然后在BasePage中overrideOnLoad函数.加入判断Session是否失效,每个继承BasePage的页面加载时都会进去OnLoad进行检测了icrud_tables/5how_housekaspxApp_Code/BaseHandlenc弋crudtablesshowbouGe▼卢Page^Loac-usingSystem:usingSystem.Collections・Generic:usingSystem・Linq:usingSystem.Web;usingSystem.Web.UI:usingSystem.Web.UI•聊巳bCciirtiSDlg;-publicpartialclass匚rud_1:abl&s_show_house:Bas&Page ppt 关于艾滋病ppt课件精益管理ppt下载地图下载ppt可编辑假如ppt教学课件下载triz基础知识ppt \■\———1-protectedvoidFage_Load(objectsender.Event^rgse){-_stringuserlevel=Convert・TdString(S巳ssioni"]);userLevel.Value=userlevel;stringDM=Convert*TcString(Session[rfdm']);dm.Value=DM;100%*-2、ashx基类的写法,我们这里定义一个为BaseHandler.cS勺基类基类里面的方法还有定义的信息就可以写在方法里面publicvoidProcessRequest(HttpContextcontext){}如果需要定义全局的变量就需要在上方定义一个公共的方法publicstringinfo="独占网络";最重要的就是要写一个虚方法,是这一个用于给继承类重写的方法publicvirtualvoidAjaxProcess(HttpContextcontext){}然后在里面调用AjaxProcesspublicvoidProcessRequest(HttpContextcontext){〃调用一个新的content类,这一个类是用于给其它继承方法重写的AjaxProcess(context);}然后接下面就是要写一个子类ashx文件,书写方法如下//记得继承的是上面我们书写的基类publicclasschlidAshx:BaseHandler{//然后重写方法就可以publicoverridevoidAjaxProcess(HttpContextcontext){//书写的您的方法}App.Code/BaseHandler.csX|BaseHandler曰/〃///BaseHandler的摘要说明///〈/summary〉BpublicclassBaseHandler:IHttpHandler,IRequiresSessionStateH耳■3ProcessRequest(HttpContextcontext)100%publicBaseHandler()//0//TODO:在比处添加构造函数逻辑//}publicvoidProcessRequest(HttpContextcontext)stringuserlevel=Convert・ToString(context・]):if(userlevel==**"||userlevel==null)context.Response・CorrterrtType=^text/html*:stringpath=context.Request・Application?ath;context.Response.Write(**alertC用户已过期,请重赣登录!):window,top.locati}elseAjaxProcess(context):publicvirtualvoidAjaxProcess(HitpContextcontext)flf绷(0WebHandlerLansuage^^C#"Clas^ffjet_fact_period"usin^System;usingSystem・Collectians^Generic;usingSys丈匕皿.Linq:usingSys耶:usingSystem・^eb・UI:usingSystem.Veb・UI*IfmbCMrtrcjL雷;usingSystem.Data;usingSystem.Text:usingSystem.Veb.,Script-Serializatitin:usingSystem.Veb.,SessianState:publicclassajct_period:BaseKandler{_'publicoverridevoidAjaxProcess(HttpCortextcontaxt){intpage=Convert.Joint32(context,Request.Params['page"]);//页索引n,ntrovs=:on戏已rt・ToIirt32(Gorrt^itt,Rpquert*Parajnw「rDww"]);stringdm=Convert.ToStrins(coirtext.Session[*dm*]1取队名stringkm=Converi,ToStrinf(contest*Session[akm^])矿名stringuserlevel=Convert.ToStrinj(context,Sessia|i["-U5erlevel"])用户级另4stringsqlstr=^sbIbc!*fr&m(sel&ctt・+jrawncuminfroni(?elect*fromT_HOUSE)twherai〃/条件查询beginstringKM=context*Request.Params「KH']:stringDM=context*Request.Params["DM']:stringZM=context*Request-Params["ZM1']:stringKSRJQ-ctintezt.R#quest.Farsms['KS3"html标签,这样可以在页面显示'Icrud_get/get_house.ashxcrud_tables/shcw_hoii5e,aspx.cscrud_tables/show_F嗨T•1ToJson(DataTablecfor(ini1=0;iReplace('\z',jsonBuilder>Append(,T\FT3r):1jsonEuiIder.Remove(jsonBuilder*Length-1,1):jsonBuilder»AppendC}/Y):1if(dt.Rows.Qdunt>0)jsonBuilder.Remove(jsonBuiIder.Leng:th-1,o:jsonEuilder・Aj)pendC]");jsonfiuilder.Append(,'/}:stringJson_data=亍T|I竺「■用”FF\出HiC4予r-I“八Ii*1i**昌昇*“T1*■TI1⑰10C%ni2、再在datagride的appendRow方法中,将"
"转化为“\n”,使其正确显示在多行文本中。3、当使用<textarea>多行文本标签时,rows和cols为<textarea>的必填属性,如果不加页面显示会有错―一一—一-----------1crudjables/show_event.aspxApp_Code/T.cscrud^get/geLhouse.ashxcrud.tables/show^house.aspx客户运对歩和爭件■氏翻牛)E)S时间记串人审核人|记事内咨II100%…1川

本文档为【C#前端开发当Session失效时,提示用户重新登录。分析】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_597436
暂无简介~
格式:doc
大小:165KB
软件:Word
页数:0
分类:
上传时间:2019-09-18
浏览量:52