First, create a new class, inherit from System. Web. UI. Page, and then override OnInit, as shown below:
Copy codeThe Code is as follows:
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 );
}
}
}
}
}
Reference the following method on the page.
Copy codeThe Code is as follows:
Public partial class QrDeptMan_Home: FuSession. JudgeSession