Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between making a handler w/ ashx/axd and using something I made up myself in ASP.NET?

This is probably very simple but it's really confusing me. When I implement the IHttpHandler, I create a handler and then register it like so in the web.config:

IIS6 Portion:
<httpHandlers>
    <add verb="*" path="*.randomextension" type="MyProgramNameSpace.MyHandler" />
</httpHandlers>

IIS7 Portion:
<handlers>
    <add name="mine" verb="*" path="*. randomextension" type ="MyProgramNameSpace.MyHandler" />
</handlers>

It seems to work quite well and get to use different handlers and options for it. It let's me skip the Page class and so forth by directly accessing the pipeline. However, every so often I keep running into documentation where it says I need to use something about ashx or axd with something.

What is all this about? How does this have to do w/ handler creations?

This is probably very easy but for some reason I'm completely confused when going about this ashx or axd handler.

like image 518
danmine Avatar asked Dec 23 '22 09:12

danmine


1 Answers

The .asxh handler is simply a pre-existing/pre-defined generic handler mapping. Unlike the .aspx handler, you are not restricted to deriving from Page, and you don't get the full ASP.NET page handler event pipeline. Generally, you use .ashx files to handle non-page requests that take as input or return as output non-standard content.

The different from an .ashx handler and a custom IHttpHandler is not much, really. A lot of configuration is predefined for .ashx files, but, you are bound to that extension. With a full custom IHttpHandler, you have complete and total freedom, but need to configure it from the ground up.

like image 131
jrista Avatar answered May 14 '23 09:05

jrista