I have a ASP.NET project that uses a custom HTTPHandler for authentication at page level Additionally I have created a HTTPModule that I want to use to scan controls on a System.Web.UI.Page to make sure they are read-only unless specified in a DB.
Normally I can get access to the Page object in an HTTPModule by using the HTTPContext.Current.Handler (see example below) because the Page object is the handler, but because I have created a custom handler the HTTPContext.Current.Handler is no longer the page but my handler instead.
How can I get access to the Page object when I have a custom HTTPHandler defined?
1 public void Init(HttpApplication httApp)
2 {
3 httApp.PreRequestHandlerExecute += new EventHandler(SetControlSecurity);
4 }
5
6 private void SetControlSecurity(object sender, EventArgs e)
7 {
8 HttpApplication app = (HttpApplication)sender;
9
10 try
11 {
12 System.Web.UI.Page currentPage = (System.Web.UI.Page)HttpContext.Current.Handler;
13 }
14 catch (Exception ex)
15 {
16
17 }
18 }