ASP.NET - question - Asked By abhishek patel on 13-Feb-12 12:09 AM

What are ASHX files?  What are HttpHandlers?  Where can they be configured?
Web Star replied to abhishek patel on 13-Feb-12 12:26 AM
A file with the ASHX file extension is an ASP.NET Web Handler file.
ASHX files are files used with ASP.NET programming and can be opened with any program that codes in ASP.NET (like Microsoft Visual Web Developer). ASHX files are not intended to be viewed or opened by the browser. If you've downloaded an ASHX file and expected it to contain information (like a document or other saved data), it's likely that something is wrong with the website and instead of generating usable information, it provided this server-side file instead.

We can use <httpHandlers> and <add> nodes for adding HTTP handlers to our Web applications. In fact the handlers are listed with <add> nodes in between <httpHandlers> and </httpHandlers> nodes. Here is a generic example of adding an HTTP handler:

see more details about both here
http://www.dotnetperls.com/ashx 
http://www.codeguru.com/csharp/.net/net_asp/article.php/c19389 
Sandeep Mittal replied to abhishek patel on 13-Feb-12 12:29 AM
Refer below posts

http://www.justinrhinesmith.com/blog/2008/05/11/ashx-files-and-httphandlers/
http://msdn.microsoft.com/en-us/library/ms227675%28v=vs.80%29.aspx
http://peterkellner.net/2008/09/06/iis7-httphandlers-handlers-integrated-mode-webfarm/
Somesh Yadav replied to abhishek patel on 13-Feb-12 12:42 AM
Hi,

An .ashx file is a placeholder for an HttpHandler. It allows you to create a IHttpHandler implementation as simply as you create a .aspx file, without any reconfiguration of web.config or other hoops. It provides you access to the Request and Responsie without any of the facilities or overhead of the page model.

HttpHandlers are low level implementations of the request/response http cycle. Using an HttpHandler, you can deliver responses back to the browser with minimal overhead. A good example of this would be a dynamic image generator that could be accessed using the  tag.

You configure HttpHandlers by registering them in web.config. You may also need to configure IIS to send certain file extension requests to aspnet_isapi.dll.
Reena Jain replied to abhishek patel on 13-Feb-12 01:40 AM
hi,

A file with the ASHX file extension is an ASP.NET Web Handler file. A handler is responsible for fulfilling requests from a browser. ASHX files are used as supporting files in ASP.NET programming and can be opened with any program that codes in ASP.NET. These generic handlers have an extension of ASHX like "filename.ashx". Requests that a browser manages are either handled by file extension or by calling the handler directly. Only one handler can be called per request.

Add a handler file by clicking on the website in the Solution Explorer and add new items "Generic Handler".


http://www.gigyonline.com/code/source/aspnet/ashxfile.html
http://www.dotnetperls.com/ashx
Suchit shah replied to abhishek patel on 13-Feb-12 01:53 AM
What is ASHX file ?
A file with the ASHX file extension is an ASP.NET Web Handler file. A handler is responsible for fulfilling requests from a browser. ASHX files are used as supporting files in ASP.NET programming and can be opened with any program that codes in ASP.NET. These generic handlers have an extension of ASHX like "filename.ashx". Requests that a browser manages are either handled by file extension or by calling the handler directly. Only one handler can be called per request. A handler does not have any HTML static text like .aspx or .ascx files. A handler is a class that implements the IHttpHandler interface. If you need to interact with any Session information, you will also need to implement IRequiresSessionState. If you want to make an asynchronus handler, you will need to implement the IHttpAsyncHandler interface instead of the IHttpHandler interface.
 

HttpHandlers have a specific use and are not used in every situation..

What is a HttpHandler?

Well a HttpHandler is used in situations where you need to "handle" the "http" request sent to your webserver in a specific or different manor. More over a Http Handler (which is the basis of all .Net managed handlers) opens up the RAW http request (and response) allowing for complete customization in dealing with the request and providing a customized response.

When you use a HttpHandler ?

A Http Handler (as said above) simply recieves and responds to a http request. Typically we use our .net (aspx) pages to handle and respond to these request. However when it comes to specific situations, IE. request for downloading a file, displaying a chart image etc... It is usually better to remove all the "un needed" events, data and sub routines required to show a full page. Http Handlers can also provide a low level access to events and data from all http requests. This allows you to "intercept" http requests and process data \ header information before your application processes the request.


Where can they be configured ?


HttpHandlers can be configured in the web.config file.

To configure you can add handler as

<configuration>
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx"
type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
...
<system.web>
</configuration>


More details

http://www.developerfusion.co.uk/show/4704/2/

Check Michael's blog about .ashx extension

http://weblogs.asp.net/mschwarz/archive/2006/04/03/Missing-.ASHX-Mapping-will-stop-Ajax.NET-running.aspx

kalpana aparnathi replied to abhishek patel on 13-Feb-12 05:05 AM
hi,

Use this link :http://rameshdotnetinfo.blogspot.in/2011/08/what-are-ashx-files-what-are.html

Regards,