WebSite建立能访问的Global

由于WebSite建立的Global文件默认是内建式的,不在appcode里,所以无法访问,这时就需要我们手动修改.

<%@ Application Codebehind="App_Code\Global.cs" Inherits="Global" Language="C#" %>

然后在app_code中加入 Global类

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Timers;
public class Global : System.Web.HttpApplication
{
    public static Timer aTimer = new Timer();

    protected void Application_Start(object sender, EventArgs e)
    {
        Global.aTimer.Elapsed += new ElapsedEventHandler(aTimer_Elapsed);
    }

    void aTimer_Elapsed(object sender, ElapsedEventArgs e)
    {
        System.Data.DataTable ds = MySqlDB.GetChangesOnLdapServer();
        if (ds.Rows.Count > 0)
        {
            MySqlDB.AddNewUser(ds);
        }
    }
    protected void Session_Start(object sender, EventArgs e)
    {

    }

    protected void Application_BeginRequest(object sender, EventArgs e)
    {

    }

    protected void Application_AuthenticateRequest(object sender, EventArgs e)
    {

    }

    protected void Application_Error(object sender, EventArgs e)
    {

    }

    protected void Session_End(object sender, EventArgs e)
    {

    }

    protected void Application_End(object sender, EventArgs e)
    {

    }

}

 

你可能感兴趣的:(global)