Last post May 27, 2009 11:11 AM by markwill
May 24, 2009 01:20 PM|markwill|LINK
I am building some URL logic that will go into an Http Module. The logic is somewhat expensive (includes a database lookup) and maps virtual URL's to the appropriate physical page.
I want to be sure that the logic isn't called if the request is for a physical page (the logic only applies to virtual URL's). How/where do I plug into the .aspx pipeline to ensure that my logic is only invoked if the request is not for a physical page?
May 26, 2009 10:37 PM|Nai-Dong Jin - MSFT|LINK
From your description, it seems that you want to active the database lookup logic only when you are requesting for a virtual url, right?
I'm not sure what your httpModule looks like, generally, you can add your custom logic to identity if the current request is virtual or physical according to your rules. For samples:
void context_BeginRequest(object sender,
May 27, 2009 11:11 AM|markwill|LINK
Thank you for your response, Michael. I may not have explained my problem very well.
I have a number of URL's that need to be mapped to physical pages. For example, let's say I have /products/category/toys as the URL that will be linked on various pages. When the request comes in I want to map that to, say, /productspage.aspx?category=toys.
Let's imagine that I have a whole bunch of these virtual -> physical mapping to do and that in some cases the mapping requires a lookup in a database. This lookup is expensive so I want to only invoke that logic when the incoming URL is NOT for an existing
virtual page. Thus, if a request comes in for /contact-us.aspx and that page is a real, live physical page, I want to bypass the aforementioned lookup logic.
Basically, I want to implement logic that bypasses my virtual page logic when the incoming page does not resolve to a physical page. I am afraid I don't really follow your suggestion since it seems to imply there is something specific in the name of the
URL (the contains() method) that I can use. This won't be the case. The trigger for my lookup code is whether the incoming request is for a physical page or not and does not have any relationship to the contents of the URL itself.