![]() |
|
|
|||||||
![]() |
ASP Net - How to get a handler for a path |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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] |
|
|
|
#5 |
|
Posts: n/a
|
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 |
|
|
|
#6 |
|
Posts: n/a
|
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] |
|
|
|
#7 |
|
Posts: n/a
|
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 |
|
|
|
#8 |
|
Posts: n/a
|
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] |
|
|
|
#9 |
|
Posts: n/a
|
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 |
|
|
|
#10 |
|
Posts: n/a
|
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] |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |