Pregunta

I have my custom HttpHandler that will be mapped to different paths and for each path I need to have specific configuration passed to handler to modify it's behavior.

My first idea is to create custom section that will hold configuration for all handlers and I would correlate instance to configuration using path.

But is there a built in way to pass custom configuration to a custom http handler?

¿Fue útil?

Solución

But is there a built in way to pass custom configuration to a custom http handler?

The <add> child element of <httpHandlers> in your web.config does not provide any means to pass any additional information to the handler (eg. an id to use as key for further configuration).

So unless each handler has a distinct type (and thus you can use the type name as a configuration key) you need to use that is passed to the instance of the handler as part of the request. Some part of the URL (or information derived from it) would seem easiest (and would allow multiple handlers for different types but the same path to share configuration).

Summary: you are on your own, and using the request path does seem reasonable.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top