Hi,
ASP.NET offers 4 types of http handlers - synchronous, asynchronous, generic synchronous (ashx) and generic asynchronous (ashx) handlers.
How do you choose the type of http handler to use for a job?
Hi,
ASP.NET offers 4 types of http handlers - synchronous, asynchronous, generic synchronous (ashx) and generic asynchronous (ashx) handlers.
How do you choose the type of http handler to use for a job?
There are no hard-and-fast rules, but here are a few guidelines for you:
sync vs. async: use sync when you don't have any long-running tasks. Use async when you do. For example, if the handler queries a database or makes a web service call, then it should be async.
generic vs. custom: use generic if you don't care about the extension in the URL (it will be *.ashx). Use custom if the extension is important (perhaps to generate custom PNG images). Full-custom handlers require an extra step to register them in web.config, but are otherwise pretty much identical to generic handlers.
Also, it may help to keep in mind that the Page class is really just an HttpHandler that happens to handle .aspx files -- and you can of course have sync and async pages, too, with the same guidelines as above.
In case it's of interest, I cover this info in detail in my book, including examples (Ultra-Fast ASP.NET).