Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 24, 2011 12:57 AM by N_EvilScott
Sep 23, 2011 07:49 PM|LINK
I have an asp.net custom server control "S" on Site A. This control has some information I need but it is rendered in the asp.net way.
I have another Site B. Here, I need some information generated by server control "S" in Site A but I don't to need to render here in Site B.
The question is can I somehow create a HttpHandler in Site A. This Handler will call a page which invokes the custom server control "S". I will alter "S" to keep all the information I need in data structure. But how can I access it from a HttpHandler? Basically
I am trying to extend my control "S" into an API of some sort.
Is this even possible? How can I get my handler to access with my custom server control. If you can give me some advice that would be great.
Sep 23, 2011 10:07 PM|LINK
The HttpHandler is used to inject items into the HttpContext for consumption, so a good example would be to create dynamic images that can be rendered on the HTML page that need to be generated at run time, versus an already saved image on server.
With that said, what you are trying to do seems more suited for the System.Net.WebClient object.
Using this object you can pass in a Uri or a string url to call the specific page from the code behind rendering your server control and grab what you need using its various methods.
You can find the WebClient specs here as well as samples:
Sep 23, 2011 11:50 PM|LINK
Thanks for repsonse.
Is there Any other way, rather then scraping? I thought about httphandler becuase I can just return the markup I need.
Sep 23, 2011 11:54 PM|LINK
If its an actual server control that you built against a class library and its referenced in your site then you can just instantiate it in the HttpHandler and perform any actions you need and then save whatever info you need into Session.
Sep 24, 2011 12:47 AM|LINK
The problem is that there is quite abit of code I need in the server control pageload structure which instaniate and initiate these classes. So it would be quite a bit of work to just make these classes work in handler. I am trying to avoid and find the
The closest I got now is, I have added some public getters for my server controls for the markup I need. I call my server control in a aspx page. When this page get hit. It loads the server control etc. In OnPreRenderComplete event I redirect to my handler.
I try to pass the markup as a param in the redirect but IIS won't do it due to size? or encoding.
Any ideas how I can pass this markup to my handler this way or any other way?
...Just hacking right now. The approach you spoke off, may be the inevitable.
Sep 24, 2011 12:57 AM|LINK
What exactly are you trying to get from it? I mean is it a huge data table or a large chunk of text or? If you tell me what you are trying to grab from it specifically I can probably be more specific on solutions