Skip to main content

Overview

The OnlyOfficeHandler.ashx is an ASP.NET HTTP handler that processes document-related requests for the OnlyOffice Control library. It implements the IHttpHandler interface and provides three main actions for document management.

Handler Endpoint

OnlyOfficeHandler.ashx?action={action}

Available Actions

The handler supports three primary actions, specified via the action query parameter:

download

Downloads a document file from the server storage.
GET OnlyOfficeHandler.ashx?action=download&fileId={fileId}
Learn more about document download →

callback

Receives document status updates from OnlyOffice Document Server when users edit or save documents.
POST OnlyOfficeHandler.ashx?action=callback&fileId={fileId}
Learn more about document callback →

proxy

Proxies external document requests to handle CORS restrictions and security validation.
GET OnlyOfficeHandler.ashx?action=proxy&url={url}
Learn more about document proxy →

Error Handling

If an invalid or missing action is provided, the handler returns:
statusCode
number
default:"400"
HTTP status code indicating bad request
body
string
default:"Invalid action"
Error message in plain text format

Example Error Response

HTTP/1.1 400 Bad Request
Content-Type: text/plain

Invalid action

File Storage

All document files are stored in the ~/App_Data/uploads directory. The handler automatically creates this directory if it doesn’t exist.

File Naming Convention

Files are stored with the pattern: {fileId}.{extension} For example:
  • doc123.docx
  • sheet456.xlsx
  • presentation789.pptx

Implementation Details

Namespace

OnlyOfficeControl.Controls.OnlyOfficeEditorBundle

Class

public class OnlyOfficeHandler : IHttpHandler
{
    public bool IsReusable => false;
}

Handler Registration

Ensure the handler is registered in your web.config:
<system.webServer>
  <handlers>
    <add name="OnlyOfficeHandler" 
         verb="*" 
         path="OnlyOfficeHandler.ashx" 
         type="OnlyOfficeControl.Controls.OnlyOfficeEditorBundle.OnlyOfficeHandler" />
  </handlers>
</system.webServer>

Security Considerations

The handler processes file operations and external requests. Ensure proper authentication and authorization are implemented at the application level before allowing access to this handler.

TLS Configuration

The handler enforces secure connections for external requests:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | 
                                       SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls;

Next Steps

Download Action

Learn how to download documents from storage

Callback Action

Handle document save callbacks from OnlyOffice

Proxy Action

Proxy external document requests

Build docs developers (and LLMs) love