From: Ole Viaud-Murat on
Hello,

i just asked myself if it was possible to create a HttpHandler that
listens to a specific path scheme like

~/reports/subpath1/subpath2/*.extension

Currently i just manage to get simple Paths to work, like:

~/reports/*.extension

So it seems that asp.net's HttpHandlers have a restriction to only
work with Paths of a depth of 1, making paths like ~/reports/subpath1/
subpath2/*.extension impossible to work for HttpHandlers.

I use a workaround in the handlers section of the web.config:

i change

<add ... path="reports/subpath1/*.csv" ... />

to

<add ... path="reportssubpath1/*.csv" ... />

And change the corresponding link-factory to create links that point
to that paths. But this seems to be pretty bad practive afaic.

I know, that the use of asp.net MVC would (hopefully?) "rectifiy" this
limitation of asp.net but perhaps i'm missing something? I'd like to
implement such thing now, before switching to mvc.

Would that be possible in asp.net 3.5, without the use of MVC?

thanks in advance for any hints

Ole

From: Ole Viaud-Murat on
Edit: the paths do not exist physically.
From: ib.dangelmeyr on
On May 5, 1:09 pm, Ole Viaud-Murat <o.viaudmu...(a)googlemail.com>
wrote:
> Edit: the paths do not exist physically.

Why don't you use url-rewriting in the global.asax file?

Try something like: (Example global.asax)

<%@ Application Language="C#" %>
<script runat="server">
void Application_BeginRequest(object sender, EventArgs e)
{
string[] parts = HttpContext.Current.Request.FilePath.Split(
new char[] {'/'}, 2, StringSplitOptions.RemoveEmptyEntries);
if ( parts.Length > 0 && parts[0].ToLower() == "products" )
HttpContext.Current.RewritePath("~/products.aspx?product=" +
(parts.Length > 1 ? parts[1] : ""));
}
</script>

This example would map all requests like

http://server/products/x/y/z/abc

to the URL

http://server/products.aspx?product=x/y/z/abc

hope it helps.