為每個(gè)頁(yè)面加上Session判斷的小例子
首先新建一個(gè)類(lèi),繼承自System.Web.UI.Page,然后重寫(xiě)OnInit,如下:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace FuSession
{
public class JudgeSession : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (Session.Keys.Count <= 0)
{
Response.Redirect("~/TiaoZh.htm", true);
}
else
{
if (Session["UserId"] == null && Session["Qx"] == null && Session["Dept"] == null && Session["UserName"] == null && Session["QxType"]==null)
{
Response.Redirect("~/TiaoZh.htm", true);
}
}
}
}
}
在頁(yè)面中按照如下方法引用即可。
public partial class QrDeptMan_Home : FuSession.JudgeSession
相關(guān)文章
asp.net繼承IHttpHandler接口實(shí)現(xiàn)給網(wǎng)站圖片添加水印功能實(shí)例
這篇文章主要介紹了asp.net繼承IHttpHandler接口實(shí)現(xiàn)給網(wǎng)站圖片添加水印功能,實(shí)例分析了asp.net基于IHttpHandler接口實(shí)現(xiàn)網(wǎng)站圖片水印功能的具體步驟與相關(guān)技巧,需要的朋友可以參考下2016-07-07
更方便快捷的外部操作數(shù)據(jù)庫(kù)的方法(另類(lèi)玩法)
數(shù)據(jù)庫(kù)操作方法很多,各種各樣但是外部操作數(shù)據(jù)庫(kù)的方法就會(huì)顯得格外陌生了,感興趣的朋友可以詳細(xì)了解下本文,或許對(duì)你學(xué)習(xí)ado.net有所幫助2013-02-02
利用EF6簡(jiǎn)單實(shí)現(xiàn)多租戶(hù)的應(yīng)用
這篇文章主要給大家介紹了關(guān)于如何利用EF6簡(jiǎn)單實(shí)現(xiàn)多租戶(hù)應(yīng)用的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用EF6具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09
Asp.Net使用Npoi導(dǎo)入導(dǎo)出Excel的方法
這篇文章主要介紹了Asp.Net使用Npoi導(dǎo)入導(dǎo)出Excel的方法,采用該方法在導(dǎo)出Excel的時(shí)候不需要office組件的支持,而在導(dǎo)入Excel的時(shí)候采用OleDb的方式,需要office組件的支持。是一個(gè)非常實(shí)用的技巧,需要的朋友可以參考下2014-09-09
Asp.Net 網(wǎng)站性能優(yōu)化之緩字決 (上) 緩沖寫(xiě)數(shù)據(jù)
通常情況下Asp.Net 網(wǎng)站的底層數(shù)據(jù)存儲(chǔ)都是關(guān)系數(shù)據(jù)庫(kù),關(guān)系數(shù)據(jù)庫(kù)資源比較昂貴,而且也很容易造成瓶頸。緩字決文章就是為大家介紹如何有效使用緩存,異步寫(xiě)緩沖數(shù)據(jù)庫(kù)的壓力,從而保證網(wǎng)站的性能。2010-06-06

