為每個頁面加上Session判斷的小例子
首先新建一個類,繼承自System.Web.UI.Page,然后重寫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);
}
}
}
}
}
在頁面中按照如下方法引用即可。
public partial class QrDeptMan_Home : FuSession.JudgeSession
相關文章
asp.net繼承IHttpHandler接口實現(xiàn)給網(wǎng)站圖片添加水印功能實例
這篇文章主要介紹了asp.net繼承IHttpHandler接口實現(xiàn)給網(wǎng)站圖片添加水印功能,實例分析了asp.net基于IHttpHandler接口實現(xiàn)網(wǎng)站圖片水印功能的具體步驟與相關技巧,需要的朋友可以參考下2016-07-07
更方便快捷的外部操作數(shù)據(jù)庫的方法(另類玩法)
數(shù)據(jù)庫操作方法很多,各種各樣但是外部操作數(shù)據(jù)庫的方法就會顯得格外陌生了,感興趣的朋友可以詳細了解下本文,或許對你學習ado.net有所幫助2013-02-02
Asp.Net 網(wǎng)站性能優(yōu)化之緩字決 (上) 緩沖寫數(shù)據(jù)
通常情況下Asp.Net 網(wǎng)站的底層數(shù)據(jù)存儲都是關系數(shù)據(jù)庫,關系數(shù)據(jù)庫資源比較昂貴,而且也很容易造成瓶頸。緩字決文章就是為大家介紹如何有效使用緩存,異步寫緩沖數(shù)據(jù)庫的壓力,從而保證網(wǎng)站的性能。2010-06-06

