It is not possible to do it the way you describe, which looks like this:
Request --> Pre-handler | Handler | Post-handler --> Response
page.asp by ASP.NET | by ASP | by ASP.NET
The ASP runtime is an ISAPI executable that the ASP.NET runtime cannot launch. That is, your ASP.NET handler code (maybe an .ashx handler in this situation) cannot create an instance of the ASP runtime and then pass it the original request for processing,
and then get hold of the output.
What you can do however is have your ASP.NET handler issue a full new web request. Say that you have updated IIS so that requests for .asp extensions are mapped to ASP.NET. You then add a new extension (say .old) which is mapped to ASP. Your ASP.NET handler
receives a request for page.asp, and then issues a new web request for the page named page.old, which will be passed by IIS to ASP. Your ASP.NET handler will get the response from ASP. Then, any post-handler processing (such as filtering that HTML response)
can occur. This process looks like this:
Request --> Pre-handler | Handler | Post-handler --> Response
page.asp by ASP.NET | by ASP.NET | by ASP.NET
| ^
| |
-------------------- --------------------
| |
----> Request --> Handler --> Response ----
page.old by ASP
To learn how your own ASP.NET handler can issue a new request, please refer to the documentation for the
WebClient class. While that would be a bit slow (as the user must wait for two requests to be processed), you can cache the result so that this is a one-time-only expensive operation. You could then add a file-dependency to that cached
output, so that should the page.old file change, this will remove ASP.NET's cached version of the page. Then, when the page is next requested, ASP.NET goes through the two-request cycle, and again caches the output with a file dependency.
SomeNewKid
All-Star
45894 Points
8027 Posts
Re: HttpHandlers and Classic ASP
Dec 30, 2005 08:03 PM|LINK
It is not possible to do it the way you describe, which looks like this:
Request --> Pre-handler | Handler | Post-handler --> Response
page.asp by ASP.NET | by ASP | by ASP.NET
The ASP runtime is an ISAPI executable that the ASP.NET runtime cannot launch. That is, your ASP.NET handler code (maybe an .ashx handler in this situation) cannot create an instance of the ASP runtime and then pass it the original request for processing, and then get hold of the output.
What you can do however is have your ASP.NET handler issue a full new web request. Say that you have updated IIS so that requests for .asp extensions are mapped to ASP.NET. You then add a new extension (say .old) which is mapped to ASP. Your ASP.NET handler receives a request for page.asp, and then issues a new web request for the page named page.old, which will be passed by IIS to ASP. Your ASP.NET handler will get the response from ASP. Then, any post-handler processing (such as filtering that HTML response) can occur. This process looks like this:
Request --> Pre-handler | Handler | Post-handler --> Response
page.asp by ASP.NET | by ASP.NET | by ASP.NET
| ^
| |
-------------------- --------------------
| |
----> Request --> Handler --> Response ----
page.old by ASP
To learn how your own ASP.NET handler can issue a new request, please refer to the documentation for the WebClient class. While that would be a bit slow (as the user must wait for two requests to be processed), you can cache the result so that this is a one-time-only expensive operation. You could then add a file-dependency to that cached output, so that should the page.old file change, this will remove ASP.NET's cached version of the page. Then, when the page is next requested, ASP.NET goes through the two-request cycle, and again caches the output with a file dependency.
Does that help you?