Hi, I have 2 pages: IntPage.aspx and StringPage.aspx with the classes declared in their respective code behind files. Both pages are declared in the root folder and work fine Then I have a CustomPageHandlerFactory class (declared in the App_Code folder): public class MyPageHandlerFactory : PageHandlerFactory { public override IHttpHandler GetHandler(HttpContext context, string requestType, string virtualPath, string path) { IHttpHandler myhandler = null; if (some boolean condition) myhandler = new IntPage(); else myhandler = new StringPage(); return myhandler; } } // class MyPageHandlerFactory But I get a compiler error on IntPage and StringPage --> "The type or namespace name 'IntPage' could not be found" "The type or namespace name 'StringPage' could not be found" It seems to me that, from a page class you can use any class declared in the App_Code folder but not the other way around. How can this be solved ? thx Chris
the pages are compiled separately into their own dll(s), so they are not known when the appcode is compiled. you need to do this lookup at runtime: var type = BuildManager.GetCompiledPageType(pagePath); var myhandler = Activator.CreateInstance(type) as IHttpHandler; -- bruce (sqlwork.com) Chris wrote: > Hi, > > I have 2 pages: IntPage.aspx and StringPage.aspx with the classes > declared in their respective code behind files. > Both pages are declared in the root folder and work fine > > Then I have a CustomPageHandlerFactory class (declared in the App_Code > folder): > > public class MyPageHandlerFactory : PageHandlerFactory > { > public override IHttpHandler GetHandler(HttpContext context, > string requestType, string virtualPath, string path) > { > IHttpHandler myhandler = null; > > if (some boolean condition) > myhandler = new IntPage(); > else > myhandler = new StringPage(); > return myhandler; > } > } // class MyPageHandlerFactory > > But I get a compiler error on IntPage and StringPage --> > "The type or namespace name 'IntPage' could not be found" > "The type or namespace name 'StringPage' could not be found" > > It seems to me that, from a page class you can use any class declared > in the App_Code folder but not the other way around. > > How can this be solved ? > > thx > Chris