public class OMSPageChecker : IHttpModule { public void Dispose() { } public void Init(HttpApplication context) { context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute); } void context_PreRequestHandlerExecute(object sender, EventArgs e) { var app = sender as HttpApplication; if (app == null) return; var page = app.Context.Handler as System.Web.UI.Page; if (page == null) return; if (page is BasePage) return; if (page is Firstelite.OMS.Redirect) return; if (page is FirsteLite.OMS.Checking.NewMarking) return; app.CompleteRequest(); app.Context.Response.Write("前端页面必须继承自 BasePage !"); } }
<httpModules> <add name="OMSPageChecker" type="OMS.OMSPageChecker, OMS"/> </httpModules>