Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - How to get a handler for a path

 
Thread Tools Search this Thread
Old 10-24-2009, 12:01 PM   #1
Default How to get a handler for a path


Hi,

Server.Transfer and Execute only accept Pages but I would like to be
able to execute handlers of any type.

I am able to do that using the IHttpHandler and IHttpHandlerFactory
interfaces but I am unable to obtain a handler for any given path.

I could use HttpHandlersSection for classic mode although I still had to
find a match manually but integrated configuration is not exposed and by
default I can't even read applicationHost.config.

Please help me getting a handler for any given path.

Thanks.

Best regards,
Marvin


Marvin Landman
  Reply With Quote
Old 10-25-2009, 12:33 AM   #2
bruce barker
 
Posts: n/a
Default Re: How to get a handler for a path
there are a couple issues. when you call server transfer, you are in the
Process method of the current running page handler. when server transfer
loads the next page, the handler knows it inside a running request, and
has code to support that state.

other handlers may not work. if they are your own, then you can load
them and call a special entry point.

-- bruce (sqlwork.com)

Marvin Landman wrote:
> Hi,
>
> Server.Transfer and Execute only accept Pages but I would like to be
> able to execute handlers of any type.
>
> I am able to do that using the IHttpHandler and IHttpHandlerFactory
> interfaces but I am unable to obtain a handler for any given path.
>
> I could use HttpHandlersSection for classic mode although I still had to
> find a match manually but integrated configuration is not exposed and by
> default I can't even read applicationHost.config.
>
> Please help me getting a handler for any given path.
>
> Thanks.
>
> Best regards,
> Marvin



bruce barker
  Reply With Quote
Old 10-25-2009, 08:31 PM   #3
Marvin Landman
 
Posts: n/a
Default Re: How to get a handler for a path
I understand that there are problems but also note that Server.Transfer
only works for System.Web.UI.Page instances not any handlers.

I actually would like to know if the given path is mapped to my handler
and if so I would execute it kind of a subrequest.

Thanks.

Marvin

bruce barker wrote:
> there are a couple issues. when you call server transfer, you are in the
> Process method of the current running page handler. when server transfer
> loads the next page, the handler knows it inside a running request, and
> has code to support that state.
>
> other handlers may not work. if they are your own, then you can load
> them and call a special entry point.
>
> -- bruce (sqlwork.com)
>
> Marvin Landman wrote:
>> Hi,
>>
>> Server.Transfer and Execute only accept Pages but I would like to be
>> able to execute handlers of any type.
>>
>> I am able to do that using the IHttpHandler and IHttpHandlerFactory
>> interfaces but I am unable to obtain a handler for any given path.
>>
>> I could use HttpHandlersSection for classic mode although I still had
>> to find a match manually but integrated configuration is not exposed
>> and by default I can't even read applicationHost.config.
>>
>> Please help me getting a handler for any given path.
>>
>> Thanks.
>>
>> Best regards,
>> Marvin



Marvin Landman
  Reply With Quote
Old 10-26-2009, 01:59 AM   #4
Allen Chen [MSFT]
 
Posts: n/a
Default Re: How to get a handler for a path
Hi Marvin,

>Please help me getting a handler for any given path.


Is my understanding correct that you want to have an HttpHandler to handle
all requests? If so you can config the varb and path as "*", like below:

<system.webServer>
...

<handlers>
...

<add name="mycustomhandler" verb="*" path="*"
type="YourHandlerClass" />

If it's not what you need could you clarify what you mean by "a handler for
any given path"?

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



Allen Chen [MSFT]
  Reply With Quote
Old 10-26-2009, 09:18 AM   #5
Marvin Landman
 
Posts: n/a
Default Re: How to get a handler for a path
Hi,

Thank you for your reply.

I have a hanlder that can handle any path but I let my users chose what
files, extensions (or wildcard) they want to handle.

So I don't know what they have configured.

And I would like to be able to get the actually configured handler for
any given path/verb so that I can know if that's mine and handle specially.

Thanks.

Marvin

Allen Chen [MSFT] wrote:
> Hi Marvin,
>
>> Please help me getting a handler for any given path.

>
> Is my understanding correct that you want to have an HttpHandler to handle
> all requests? If so you can config the varb and path as "*", like below:
>
> <system.webServer>
> ...
>
> <handlers>
> ...
>
> <add name="mycustomhandler" verb="*" path="*"
> type="YourHandlerClass" />
>
> If it's not what you need could you clarify what you mean by "a handler for
> any given path"?
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> .
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-us/subs...#notifications.
>
> Note: MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 2 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions. Issues of this
> nature are best handled working with a dedicated Microsoft Support Engineer
> by contacting Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>



Marvin Landman
  Reply With Quote
Old 10-27-2009, 05:22 AM   #6
Allen Chen [MSFT]
 
Posts: n/a
Default Re: How to get a handler for a path
Hi Marvin,

>Thank you for your reply.


>I have a hanlder that can handle any path but I let my users chose what
>files, extensions (or wildcard) they want to handle.


>So I don't know what they have configured.


>And I would like to be able to get the actually configured handler for
>any given path/verb so that I can know if that's mine and handle specially.


I'm a little confused. Is my understanding correct that:

1. You have control over the HttpHandler class only.
2. You don't know how the users of HttpHandler set their web.config and CAS
of server machine.
3. With above restrictions, you still want your HttpHandler to handle all
requests.

Am I right? If so as far as I know there's no way to do so because it's
insecure. If my understanding is wrong could you please clarify what you
want to do?

BTW, have you tried HttpModule? Can it solve this issue?

http://msdn.microsoft.com/en-us/libr...58(VS.71).aspx

Regards,
Allen Chen
Microsoft Online Support



Allen Chen [MSFT]
  Reply With Quote
Old 10-28-2009, 09:05 AM   #7
Marvin Landman
 
Posts: n/a
Default Re: How to get a handler for a path
Allen Chen [MSFT] worte:
> 1. You have control over the HttpHandler class only.


I let my usesr decide what extension/files they handle with my
HttpHandler and as a result I can't know their settings.

> 2. You don't know how the users of HttpHandler set their web.config and CAS
> of server machine.


I can demand full-trust if that's required but I don't want to require
Local System privileges to read applicationHost.config.

> 3. With above restrictions, you still want your HttpHandler to handle all
> requests.


I don't want to handle all requests I just want to let my users decide
what requests they handle but later I need to know if a given path is
handled by my hander because my system has a sub-request like feature
that needs this information.

> Am I right? If so as far as I know there's no way to do so because it's
> insecure. If my understanding is wrong could you please clarify what you
> want to do?


I don't want to modify anything I just would like to be able to get a
HttpHandler type for any given path in the ASP.NET application even in
integrated pipeline mode.

> BTW, have you tried HttpModule? Can it solve this issue?


I believe that HttpModules are not relevant for this issue.

Thanks.

Marvin


Marvin Landman
  Reply With Quote
Old 10-29-2009, 02:51 AM   #8
Allen Chen [MSFT]
 
Posts: n/a
Default Re: How to get a handler for a path
Hi Marvin,

>I don't want to handle all requests I just want to let my users decide
>what requests they handle but later I need to know if a given path is
>handled by my hander because my system has a sub-request like feature
>that needs this information.


Thanks for your reply. Could you elaborate what your "sub-request like
feature" is? Why it needs to know whether your handler can handle a given
path? We probably can work out another approach to solve the underlying
problem if you could provide more detailed information.

BTW, is it possible to send a HTTP reqeust to that given path in your
"sub-request like feature"? By checking the HTTP response we can know
whether it's handled by your handler. (in your HttpHandler, you can add
specific HTTP header or return specific content in response to notify that
it's handled by your handler)

Regards,
Allen Chen
Microsoft Online Support



Allen Chen [MSFT]
  Reply With Quote
Old 10-30-2009, 08:43 AM   #9
Marvin Landman
 
Posts: n/a
Default Re: How to get a handler for a path
Allen Chen [MSFT] wrote:
> Hi Marvin,
>
>> I don't want to handle all requests I just want to let my users decide
>> what requests they handle but later I need to know if a given path is
>> handled by my hander because my system has a sub-request like feature
>> that needs this information.

>
> Thanks for your reply. Could you elaborate what your "sub-request like
> feature" is? Why it needs to know whether your handler can handle a given
> path? We probably can work out another approach to solve the underlying
> problem if you could provide more detailed information.
>
> BTW, is it possible to send a HTTP reqeust to that given path in your
> "sub-request like feature"? By checking the HTTP response we can know
> whether it's handled by your handler. (in your HttpHandler, you can add
> specific HTTP header or return specific content in response to notify that
> it's handled by your handler)


Thank you for your reply.

I only need to know if a given path is handled by my handler and throw
an exception (or present an error) otherwise.

I can't use Server.Execute because that requires handlers derived from
System.Web.UI.Page, and even if I used a handler derived from Page,
Server.Execute would execute real Pages (.aspx) as well that I don't
want to.

I could (with some extra work) use system.web/httpHandlers but I have no
idea how to get a hanlder in integrated mode.

Marvin


Marvin Landman
  Reply With Quote
Old 11-02-2009, 02:04 AM   #10
Allen Chen [MSFT]
 
Posts: n/a
Default Re: How to get a handler for a path
Hi Marvin,

>I only need to know if a given path is handled by my handler and throw
>an exception (or present an error) otherwise.


Thanks for your clarification. Then how about this simple approach
mentioned in my previous reply:

Is it possible to send a HTTP reqeust to that given path in your
"sub-request like feature"? By checking the HTTP response we can know
whether it's handled by your handler. (in your HttpHandler, you can add
specific HTTP header or return specific content in response to notify that
it's handled by your handler)

You can use WebClient to request that path and check the response. Can it
solve this issue?

Regards,
Allen Chen
Microsoft Online Support



Allen Chen [MSFT]
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Catching Google Search Keywords Using Http Handler Class nagaraj309 Software 0 12-02-2008 06:43 AM
example of Server.Transfer and Context Handler hanusoft Software 0 09-22-2007 07:44 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46