What is the ASHX file format?
The .ashx extension identifies an ASP.NET Generic HTTP Handler - a server-side component developed by Microsoft. Unlike a standard ASP.NET page, an .ashx handler processes HTTP requests directly and streams a response (binary data, JSON, images, or files) without the full page-rendering overhead of a regular .aspx page.
A genuine .ashx source file is plain text. It begins with a directive line such as <%@ WebHandler Language="C#" Class="MyHandler" %>, followed by a class implementing the IHttpHandler interface. Code inside is written in C# or VB.NET; the volume is often relatively small, since handlers are purpose-built for a single task.
.ashx files may appear unexpectedly when attempting to download a file from a website. This occurs when a handler serving the file - an image, a PDF document, or another resource - does not set the correct Content-Disposition header, so the browser saves the response with an .ashx suffix instead of the intended extension.
To recover such a file, you may use a simple trick: rename it by changing .ashx to the correct extension (for example, .pdf for a PDF document, or .jpg for an image), then try to open it with any application that supports that format. The same method applies to other file types - simply change the extension to the proper one and open the file with a program that supports the given format.
Security & safety
RISK: LOWThe .ashx extension itself says nothing about safety - in a URL it's just an endpoint of a normal website; treat the site as you would any (watch for phishing on login pages). A download that arrived as .ashx is typically the real file (PDF, image) with the wrong name and is safe to rename and open. Only be cautious with unexpected .ashx downloads from untrusted sources - inspect them as text or by their real type before opening, and never run anything they try to launch.
Format details
in a nutshellPrograms that open ASHX files
Technical details
deep spec| Developer | Microsoft |
| Platform | ASP.NET (.NET Framework; also supported in early ASP.NET Core compatibility mode) |
| File content | Plain text; opens with a `<%@ WebHandler %>` directive followed by a C# or VB.NET class body |
| Implemented interface | `IHttpHandler` (synchronous) or `IHttpAsyncHandler` (asynchronous operations) |
| Directive syntax | `<%@ WebHandler Language="C#" Class="ClassName" %>` |
| Supported languages | C# and VB.NET |
| Default MIME type | `text/html`; the handler overrides this by setting `context.Response.ContentType` before writing output |
| URL access pattern | Invoked directly as a URL endpoint (e.g., `download.ashx?id=1`); not a rendered browser page |
| Server registration | Mapped in `web.config` or IIS handler mappings; the ASP.NET runtime routes matching requests to the handler class |
| Binary signature | None - plain text file with no magic bytes; source files are identifiable only by the opening directive line |
| Session state | Disabled by default; enabled by implementing `IRequiresSessionState` on the handler class |
| Common uses | File downloads, dynamic image generation, AJAX/JSON endpoints, streaming binary or text data |
| Modern replacement | ASP.NET Core middleware, Minimal APIs, and `IEndpointRouteBuilder` extensions replace `.ashx` in .NET 5 and later |
| Download artifact behavior | Browsers save `.ashx` as the file suffix when a handler omits `Content-Disposition`; renaming to the real extension (`.pdf`, `.jpg`, etc.) recovers the file |
| Released | 2002 (ASP.NET 1.0, .NET Framework) |
| Specification | learn.microsoft.com |
ASHX conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about ASHX files.