By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 IT Pros & Developers. It's quick & easy.

httpHandlers for child directories

P: n/a
How would I set up an httpHandler so that it would only apply to certain
child directories of the application?

I.E:
<httpHandlers>
<add verb="*" path="/files/*/*/*/*.aspx"
type="App.HttpHandlers.ThreeDeepPage, App" />
<add verb="*" path="/files/*/*/*.aspx"
type="App.HttpHandlers.TwoDeepPage, App" />
</httpHandlers>

The wildcard character for a directory causes an error, and before I even
tried it I thought it would. I am guessing I would probably have to do this
using a custom configSection, but I'm not sure how to do it.
TIA,

Grant
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Why don't you just list them out?

<add verb="*" path="/files/certain1/bob.axd", type="..." />
<add verb="*" path="/files/certain2/bob.axd", type="..." />
<add verb="*" path="/files/certain2/deeper/bob.axd", type="..." />

bill

"Grant Harmeyer" <ne*@internetapollo.com> wrote in message
news:eO**************@TK2MSFTNGP11.phx.gbl...
How would I set up an httpHandler so that it would only apply to certain
child directories of the application?

I.E:
<httpHandlers>
<add verb="*" path="/files/*/*/*/*.aspx"
type="App.HttpHandlers.ThreeDeepPage, App" />
<add verb="*" path="/files/*/*/*.aspx"
type="App.HttpHandlers.TwoDeepPage, App" />
</httpHandlers>

The wildcard character for a directory causes an error, and before I even
tried it I thought it would. I am guessing I would probably have to do this using a custom configSection, but I'm not sure how to do it.
TIA,

Grant

Nov 18 '05 #2

P: n/a
The directories will have dynamic names for years, months and days. Also,
the file names will be dynamic (managed by a file system of sorts that I
don't have much control over).

i.e:
<add verb="*" path="/files/2004/10/7/SomeFile.axd", type="..." />
<add verb="*" path="/files/2004/12/15/SomeFile2.axd", type="..." />

Considering that I have no idea how many files there may be or what the 2nd
or 3rd level directory names may be, I was hoping to use wildcards to
achieve this. It's an odd problem I know.

Grant
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message
news:On*************@TK2MSFTNGP12.phx.gbl...
Why don't you just list them out?

<add verb="*" path="/files/certain1/bob.axd", type="..." />
<add verb="*" path="/files/certain2/bob.axd", type="..." />
<add verb="*" path="/files/certain2/deeper/bob.axd", type="..." />

bill

"Grant Harmeyer" <ne*@internetapollo.com> wrote in message
news:eO**************@TK2MSFTNGP11.phx.gbl...
How would I set up an httpHandler so that it would only apply to certain
child directories of the application?

I.E:
<httpHandlers>
<add verb="*" path="/files/*/*/*/*.aspx"
type="App.HttpHandlers.ThreeDeepPage, App" />
<add verb="*" path="/files/*/*/*.aspx"
type="App.HttpHandlers.TwoDeepPage, App" />
</httpHandlers>

The wildcard character for a directory causes an error, and before I even
tried it I thought it would. I am guessing I would probably have to do

this
using a custom configSection, but I'm not sure how to do it.
TIA,

Grant


Nov 18 '05 #3

P: n/a
Hi there,
are you sure that HttpHandler is even able to handle child directories? I
red somewhere that for each subdirectory it's own configuration should be
done (I mean: bin directory, IIS configuration, web.config...).

Are you maybe mixing HttpModule with it?

Please correct me if I'm wrong,

Igor

"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Okay, here is the path you want to take then.

<add verb="*" path="/files/Level1Handler.axd", type="..." />
<add verb="*" path="/files/Level2Handler.axd", type="..." />

In Global.cs, you will want to use HttpContext.RewritePath to achieve
this.

Here is a test snippet I used. You might want to explore the Request
object
to see if there is a better way, but RawUrl works for demostration
purposes.

protected void Application_BeginRequest( object sender, EventArgs e )
{
string url = Context.Request.RawUrl.ToUpper();
if ( url.EndsWith( "LEVEL1HANDLER.AXD" ) ) //this will covert
"files/*/Level1Handler.axd"
{
Context.RewritePath( "/files/Level1Handler.axd" );
}
else if ( url.EndsWith( "LEVEL2HANDLER.AXD" ) )
{
Context.RewritePath( "/files/Level2Hanlder.axd" );
}
}

I hope this is what you are looking for. Or atleast you can use this to
get
where you are going.

bill

"Grant Harmeyer" <ne*@internetapollo.com> wrote in message
news:u$**************@TK2MSFTNGP11.phx.gbl...
The directories will have dynamic names for years, months and days. Also,
the file names will be dynamic (managed by a file system of sorts that I
don't have much control over).

i.e:
<add verb="*" path="/files/2004/10/7/SomeFile.axd", type="..." />
<add verb="*" path="/files/2004/12/15/SomeFile2.axd", type="..." />

Considering that I have no idea how many files there may be or what the

2nd
or 3rd level directory names may be, I was hoping to use wildcards to
achieve this. It's an odd problem I know.

Grant
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in
message
news:On*************@TK2MSFTNGP12.phx.gbl...
> Why don't you just list them out?
>
> <add verb="*" path="/files/certain1/bob.axd", type="..." />
> <add verb="*" path="/files/certain2/bob.axd", type="..." />
> <add verb="*" path="/files/certain2/deeper/bob.axd", type="..." />
>
> bill
>
> "Grant Harmeyer" <ne*@internetapollo.com> wrote in message
> news:eO**************@TK2MSFTNGP11.phx.gbl...
>> How would I set up an httpHandler so that it would only apply to certain >> child directories of the application?
>>
>> I.E:
>> <httpHandlers>
>> <add verb="*" path="/files/*/*/*/*.aspx"
>> type="App.HttpHandlers.ThreeDeepPage, App" />
>> <add verb="*" path="/files/*/*/*.aspx"
>> type="App.HttpHandlers.TwoDeepPage, App" />
>> </httpHandlers>
>>
>> The wildcard character for a directory causes an error, and before I even >> tried it I thought it would. I am guessing I would probably have to do
> this
>> using a custom configSection, but I'm not sure how to do it.
>>
>>
>> TIA,
>>
>> Grant
>>
>>
>
>



Nov 18 '05 #4

P: n/a
Yes, Handlers can "handle" child directories.

For each subdirectory, its full configuration should be done when each
subdirectory is set up as an application in IIS. If a subdirectory is not
set up as an application, it will pull it settings from the parent (root
application) directory. Each subdirectory can override its parent settings,
such as appSettings, etc.

http://msdn.microsoft.com/library/de...chitecture.asp

Infact if you try to change the authentication mode for a non-application
subdirectory, it will not allow it. It will give you some "machine beyond
application configuration error".

bill
"Igor K" <ig**@exor.hr> wrote in message
news:e7**************@TK2MSFTNGP15.phx.gbl...
Hi there,
are you sure that HttpHandler is even able to handle child directories? I
red somewhere that for each subdirectory it's own configuration should be
done (I mean: bin directory, IIS configuration, web.config...).

Are you maybe mixing HttpModule with it?

Please correct me if I'm wrong,

Igor

"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Okay, here is the path you want to take then.

<add verb="*" path="/files/Level1Handler.axd", type="..." />
<add verb="*" path="/files/Level2Handler.axd", type="..." />

In Global.cs, you will want to use HttpContext.RewritePath to achieve
this.

Here is a test snippet I used. You might want to explore the Request
object
to see if there is a better way, but RawUrl works for demostration
purposes.

protected void Application_BeginRequest( object sender, EventArgs e )
{
string url = Context.Request.RawUrl.ToUpper();
if ( url.EndsWith( "LEVEL1HANDLER.AXD" ) ) //this will covert
"files/*/Level1Handler.axd"
{
Context.RewritePath( "/files/Level1Handler.axd" );
}
else if ( url.EndsWith( "LEVEL2HANDLER.AXD" ) )
{
Context.RewritePath( "/files/Level2Hanlder.axd" );
}
}

I hope this is what you are looking for. Or atleast you can use this to
get
where you are going.

bill

"Grant Harmeyer" <ne*@internetapollo.com> wrote in message
news:u$**************@TK2MSFTNGP11.phx.gbl...
The directories will have dynamic names for years, months and days. Also, the file names will be dynamic (managed by a file system of sorts that I don't have much control over).

i.e:
<add verb="*" path="/files/2004/10/7/SomeFile.axd", type="..." />
<add verb="*" path="/files/2004/12/15/SomeFile2.axd", type="..." />

Considering that I have no idea how many files there may be or what the

2nd
or 3rd level directory names may be, I was hoping to use wildcards to
achieve this. It's an odd problem I know.

Grant
"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in
message
news:On*************@TK2MSFTNGP12.phx.gbl...
> Why don't you just list them out?
>
> <add verb="*" path="/files/certain1/bob.axd", type="..." />
> <add verb="*" path="/files/certain2/bob.axd", type="..." />
> <add verb="*" path="/files/certain2/deeper/bob.axd", type="..." />
>
> bill
>
> "Grant Harmeyer" <ne*@internetapollo.com> wrote in message
> news:eO**************@TK2MSFTNGP11.phx.gbl...
>> How would I set up an httpHandler so that it would only apply to

certain
>> child directories of the application?
>>
>> I.E:
>> <httpHandlers>
>> <add verb="*" path="/files/*/*/*/*.aspx"
>> type="App.HttpHandlers.ThreeDeepPage, App" />
>> <add verb="*" path="/files/*/*/*.aspx"
>> type="App.HttpHandlers.TwoDeepPage, App" />
>> </httpHandlers>
>>
>> The wildcard character for a directory causes an error, and before I

even
>> tried it I thought it would. I am guessing I would probably have to do > this
>> using a custom configSection, but I'm not sure how to do it.
>>
>>
>> TIA,
>>
>> Grant
>>
>>
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.