Last post Jun 09, 2010 05:33 AM by Song-Tian - MSFT
Jun 08, 2010 05:02 AM|brendan.hill|LINK
I have an unusual request - I need to be able to call an arbitrary .aspx page from another page within the same application. I'm developing a highly modular architecture, and require the flexibility to call the page directly from a browser OR from another
page. The page returns content, not data, so a web method won't suffice, and at this stage I don't think web controls are going to integrate well with the design.
Worst case scenario, I can get the calling page to make a whole HTTP request to the callee page, which is basically guaranteed to work.
However a far better solution is to somehow take advantage of the fact that they're right next to each other in the same web application, can somehow call it through the HttpHandler objects.
I faffed around with System.Web.UI.PageHandlerFactory object for a while and learnt a lot in the process, but didn't find a solution.
Any ideas? I'm comfortable writing a custom HttpHandler if this will solve the problem, and preserve default functionality for the rest of the pages.
Thanks in advance,
Jun 08, 2010 05:25 AM|brendan.hill|LINK
My impression is that HttpHandlers might be too late - they deal with the request after it's come in, but I need to work out how to make it come in (internally from the application itself) in the first place.
To give some context - a .aspx page may have 4 modules (or components) displayed, all from the same web application. Now it's possible for the browser itself to load each of these 4 modules through AJAX. However, this would result in 5 web requests from
the browser to load the whole page instead of just one. Therefore, for efficiency, I would like the parent page to be able to populate itself with each of the 4 modules before returning to the client.
Now that I think of it - would it be possible to call the aspnet_isapi.dll method directly? Seems a bit sneaky, but could do the job nicely - asp.net wouldn't be able to distinguish if done properly.
P.S. It may not be as critical as I thought - the latency for a self-HTTP request is about 1.3ms, unnoticeable even on the most complex of pages.
However pulling off a genuinely internal call would be preferable, and certainly help to reduce congestion and unnecessary requests. Making a HTTP call for the page right next to you seems like an awful waste, kind of like using the phone to call the colleague
sitting right next to you....
Jun 09, 2010 05:33 AM|Song-Tian - MSFT|LINK
I suggest you reading this article first:http://www.codeproject.com/KB/aspnet/HttpModuleandHttpHandle.aspx.