I am working on a project which requires us to capture HTML content from two different portals (one in Classic ASP and another one in ASP.Net).
Here's the scenario:
1) User logs in into the ASP/ASP.Net portal
2) Goes to a search page and enter search criteria
3) Website returns the results by pulling the info from the database
4) At that time, it should also capture the HTML content (possibly using HTTPHandlers??)
I need some architectural inputs as to what would be the most effective way from architecture perspective to implement a solution that can work for both ASP and ASP.Net.
Some of the main considerations are:
1) Single component that works for both the solutions (Portal in ASP and ASP.Net)
This will definitely work for ASP.NET content - anything that goes through the Response.Write pipeline. I don't think this will work for classic ASP, which outputs data in a different way though. For that I believe you would need an ISAPI filter.
As part of your business logic , i'll suggest you to use Web Services , typically REST based services , and write the entire business logic there, once done this service layer can be exposed to any client ASP , ASP.NET or even PHP for that matter. REST enabled
services are a good choice in my opinion.
I am wondering if you can explain a little bit on your approach towards the solution. How can I utilize a REST based service in this scenario to build a reusable component that can be used in both ASP and ASP.Net portals.
It would be a lot helpful if you can share more details on exactly how this can be done.
I would also like to know the advantages to have a REST based service over a simple .Net component (DLL).
hey, sorry , my bad i didn't read the thread carefully, WCF or web services can't help you here , you need some response capturing mechanism like one mentioned above.
I have gone through your article wherein you're using Response.Filter to capture HTML content. Although I have yet to try this mechanism.
It seems to suffice my requirement.
I just want to confirm with you one thing. Should I be writing an HTTP module as you had suggested to capture the HTML content of the requested page after it has been processed? From your article on "Low level look at ASP.Net", it seems that I should write
code in PostRequestHandlerExecute() method and use ResponseFilterStream class by initializing it with Response.Filter property.
Please let me know if my understanding is correct or not.
ResponseFilterStream class seems to work fine for me. I have implemented it in an HTTPModule and using its functionality in "PostRequestHandlerExecute" event.
Since the module executes for every request, I want it to get executed when a request comes for only certain pages.
An HTTPHandler can easily be configured through a web.config to work only as per the mapping done in the web.config. Unfortunately, I couldn't get the Handler to work with the ResponseFilterStream, as it doesn't show the output of the original page the user
had requested and instead shows an empty page. I think it could be because the Handler is getting executed instead of my page (which is another Handler). I hope I am not confusing anyone here.
Since the Handler executes prior to the page processing so that tends me to think that that is probably why I don't see any output of the page that was originally requested through the browser.
How can I have a Handler work with an HTTPModule so that the HTTPModule can be executed only for those requests or pages which are mapped in the web.config for the Handler.
It would be very helpful if this is doable as I would not be wasting the server resources by getting my HTTPModule executed on every request.
raringsunny
Member
133 Points
109 Posts
HTTP Handler to capture HTML Content
Oct 20, 2011 04:43 AM|LINK
Hi:
I am working on a project which requires us to capture HTML content from two different portals (one in Classic ASP and another one in ASP.Net).
Here's the scenario:
1) User logs in into the ASP/ASP.Net portal
2) Goes to a search page and enter search criteria
3) Website returns the results by pulling the info from the database
4) At that time, it should also capture the HTML content (possibly using HTTPHandlers??)
I need some architectural inputs as to what would be the most effective way from architecture perspective to implement a solution that can work for both ASP and ASP.Net.
Some of the main considerations are:
1) Single component that works for both the solutions (Portal in ASP and ASP.Net)
2) Ease of deployment
3) Performance intensive
Any help is appreciated!
--raringsunny
rstrahl
Contributor
2233 Points
375 Posts
ASPInsiders
MVP
Re: HTTP Handler to capture HTML Content
Oct 20, 2011 07:01 AM|LINK
You can probably create a module and set up a Response.Filter in it to capture output.
See if this helps:
http://www.west-wind.com/weblog/posts/2009/Nov/13/Capturing-and-Transforming-ASPNET-Output-with-ResponseFilter
This will definitely work for ASP.NET content - anything that goes through the Response.Write pipeline. I don't think this will work for classic ASP, which outputs data in a different way though. For that I believe you would need an ISAPI filter.
+++ Rick ---
West Wind Technologies
Making waves on the Web
www.west-wind.com/weblog
shashankgwl
All-Star
18926 Points
3662 Posts
Re: HTTP Handler to capture HTML Content
Oct 20, 2011 07:04 AM|LINK
As part of your business logic , i'll suggest you to use Web Services , typically REST based services , and write the entire business logic there, once done this service layer can be exposed to any client ASP , ASP.NET or even PHP for that matter. REST enabled services are a good choice in my opinion.
All is well if it runs well.
blog
raringsunny
Member
133 Points
109 Posts
Re: HTTP Handler to capture HTML Content
Oct 21, 2011 05:07 AM|LINK
Thanks Rick for your response to my question.
I have gone through your article at a high level.
I have understood it partially. I'm planning to do a small proof of concept and then I might have few questions.
Thanks,
sunny
raringsunny
Member
133 Points
109 Posts
Re: HTTP Handler to capture HTML Content
Oct 24, 2011 05:17 AM|LINK
Thanks for the response shashankgwl.
I am wondering if you can explain a little bit on your approach towards the solution. How can I utilize a REST based service in this scenario to build a reusable component that can be used in both ASP and ASP.Net portals.
It would be a lot helpful if you can share more details on exactly how this can be done.
I would also like to know the advantages to have a REST based service over a simple .Net component (DLL).
shashankgwl
All-Star
18926 Points
3662 Posts
Re: HTTP Handler to capture HTML Content
Oct 25, 2011 11:20 AM|LINK
hey, sorry , my bad i didn't read the thread carefully, WCF or web services can't help you here , you need some response capturing mechanism like one mentioned above.
All is well if it runs well.
blog
raringsunny
Member
133 Points
109 Posts
Re: HTTP Handler to capture HTML Content
Oct 26, 2011 06:04 AM|LINK
no problems. Thanks for a response though.
raringsunny
Member
133 Points
109 Posts
Re: HTTP Handler to capture HTML Content
Oct 26, 2011 06:10 AM|LINK
Hi Rick,
I was able to write an HTTPHandler and make it work with an ASP.Net site. However, we have discovered that it is actually a SharePoint portal.
So we need to do the same thing in SharePoint instead.
We need to write a handler for SharePoint site and capture the HTML content.
Any ideas on how it can be done? I read a few articles about this subject and found some basic information.
At a high level, to achieve this in SharePoint:
1) Write a DLL in .Net and deploy that in GAC
2) Point to the assembly in GAC through a .ashx file.
Besides this what I am specifically looking for:
1) How to capture the HTML content of a SharePoint site page in ProcessRequest() method of the handler?
Regards,
--Sunny
raringsunny
Member
133 Points
109 Posts
Re: HTTP Handler to capture HTML Content
Oct 27, 2011 01:37 AM|LINK
Rick:
I have gone through your article wherein you're using Response.Filter to capture HTML content. Although I have yet to try this mechanism.
It seems to suffice my requirement.
I just want to confirm with you one thing. Should I be writing an HTTP module as you had suggested to capture the HTML content of the requested page after it has been processed? From your article on "Low level look at ASP.Net", it seems that I should write code in PostRequestHandlerExecute() method and use ResponseFilterStream class by initializing it with Response.Filter property.
Please let me know if my understanding is correct or not.
Thanks,
Sunny
raringsunny
Member
133 Points
109 Posts
Re: HTTP Handler to capture HTML Content
Oct 28, 2011 12:48 AM|LINK
ResponseFilterStream class seems to work fine for me. I have implemented it in an HTTPModule and using its functionality in "PostRequestHandlerExecute" event.
Since the module executes for every request, I want it to get executed when a request comes for only certain pages.
An HTTPHandler can easily be configured through a web.config to work only as per the mapping done in the web.config. Unfortunately, I couldn't get the Handler to work with the ResponseFilterStream, as it doesn't show the output of the original page the user had requested and instead shows an empty page. I think it could be because the Handler is getting executed instead of my page (which is another Handler). I hope I am not confusing anyone here.
Since the Handler executes prior to the page processing so that tends me to think that that is probably why I don't see any output of the page that was originally requested through the browser.
How can I have a Handler work with an HTTPModule so that the HTTPModule can be executed only for those requests or pages which are mapped in the web.config for the Handler.
It would be very helpful if this is doable as I would not be wasting the server resources by getting my HTTPModule executed on every request.
--raringsunny