HELP!!! Dispatching a Custom Web Handler On An STA Threadhttp://forums.asp.net/t/751711.aspx/1?HELP+Dispatching+a+Custom+Web+Handler+On+An+STA+ThreadFri, 19 Nov 2004 18:42:39 -0500751711751711http://forums.asp.net/p/751711/751711.aspx/1?HELP+Dispatching+a+Custom+Web+Handler+On+An+STA+ThreadHELP!!! Dispatching a Custom Web Handler On An STA Thread I created a front-end controller and need to duplicate the behavior that ASP.Net provides when you have the aspcompat attribute in the @Page directive set to true. This means dispatching the request to process the resource (in this case an asp page) on an STA thread. Here in lies the problem. Since the current thread has already been dispatched on an MTA thread, by the time my handler is invoked, setting the ApartmentState property to STA has no effect. That means I'm forced to create new thread to execute the code used to compile and render the page (or pull from the .Net STA thread pool - which I have no idea how to do). When I spawn a new thread to process the page, however, I get no HTML output??? WHY? Even more confounding - there is no error message generated! I know the thread is dispatched and I know that it terminates correctly. I also know that the code works when it is run on the current thread and is used to process a resource that does not have a reference to a COM object that requires an STA. ***HOW DOES THE ASP.NET HANDLER DO IT?????? The PageParser seems to completely ignore the aspcompat attribute when invoked by my handler. Which leads me to the conclusion that a.) ASP.NET does not use this parser to render pages with the aspcompat attribute. or b.) It's MAGIC : ) CAN ANY ONE HELP>>>PLEASE! The code I'm executing is below: System.Web.IHttpHandler page = System.Web.UI.PageParser.GetCompiledPageInstance(Context.Request.Url.LocalPath,Context.Server.MapPath(Context.Request.Url.LocalPath), Context); page.ProcessRequest(Context); You can create an aspx page with the aspcompat attribute set to true and add the following lines of code (VB.NET in this case- sorry ; ) This works just peachy if you use ASP.NET. Create your own handler and attempt to use the code above to compile and render the page, however, and it's another story!! AND YES I realize none of this is supported, encouraged, and or condoned by Microsoft and there are no warranties expressed nor implied blah blah blah... but since when did anyone let that stop them. 2004-11-19T18:25:55-05:00