What is the difference between creating a w / ashx / axd handler and using something that I created in ASP.NET?

It's probably very simple, but it really baffles me. When I implement IHttpHandler, I create a handler and then register it in the web.config file as well:

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 allows you to use different handlers and options for it. This allowed me to skip the page class, etc., by directly accessing the pipeline. However, every so often I continue to work in the documentation, which says that I need to use something about ashx or axd.

What is it? How should w / handler creations do this?

This is probably very simple, but for some reason I am completely confused when I move on to this ashx or axd method.

+4
source share
3 answers

An .asxh handler is just a predefined / predefined general display of handlers. Unlike the .aspx handler, you are not limited to creating the page, and you are not getting the full ASP.NET page handler pipeline. Typically, you use .ashx files to process non-page requests that accept as input or return as non-standard content output.

Unlike the .ashx handler and the custom IHttpHandler, this is not much. A large configuration is predefined for .ashx files, but you are tied to this extension. With full custom IHttpHandler, you have complete and complete freedom, but you need to configure it from scratch.

+6
source

There really is no difference ..ashx implement IHttpHandler just like you do. Only .ashx is a pre-registered handler, so you do not need to add it to the web.config file that it already made for you.

+3
source

If you decide to use the file type extension, your handler will be suitable.

If, on the other hand, you are trying to return data without any extension, the ashx / ahd extension is just as good.

For example, if you have a collection of images stored in a database, you can register a .JPG handler that would pull an image from the database instead of the hard drive. You can also create an ASHX that could return any type of image.

Registering the extension can make the URL more β€œnormal” for the end user, while ashx looks more general (even geeky).

+2
source

All Articles