WopiHost
The most advanced .NET implementation of the WOPI protocol. Enables integration with WOPI clients such as Office Online Server.
Install / Use
/learn @petrsvihlik/WopiHostREADME
WopiHost
| Package | Version | Downloads |
| ------------- | :-------------: | :-------------: |
| WopiHost.Abstractions | |
|
|
WopiHost.Core | |
|
|
WopiHost.Discovery | |
|
|
WopiHost.FileSystemProvider | |
|
|
WopiHost.MemoryLockProvider | |
|
|
WopiHost.Url | |
|
Introduction
This project is a sample implementation of a WOPI host. Basically, it allows developers to integrate custom datasources with Office Online Server (formerly Office Web Apps) or any other WOPI client by implementing a bunch of interfaces.
Architecture
The WopiHost project is built using a modular architecture that separates concerns and allows for flexible implementations. Here's how the modules work together:
graph TB
subgraph "Sample Applications"
SampleApps["**Sample Applications**<br/>🌐 **WopiHost.Web**<br/>🧪 **WopiHost.Validator**<br/>📝 **WopiHost Sample**"]
end
subgraph "WOPI Client"
OOS["**Office Online Server**<br/>Microsoft 365 for the Web"]
end
subgraph "WopiHost Backend API"
WopiHost["**WopiHost**<br/>Host Application"]
Core["**WopiHost.Core**<br/>Controllers & Implementation"]
subgraph "Core Libraries"
Abstractions["**WopiHost.Abstractions**<br/>Core Interfaces"]
Discovery["**WopiHost.Discovery**<br/>Client Capabilities"]
Url["**WopiHost.Url**<br/>URL Generation"]
end
subgraph "Providers"
FileSystem["**WopiHost.FileSystemProvider**<br/>File System Storage"]
MemoryLock["**WopiHost.MemoryLockProvider**<br/>In-Memory Locking"]
CustomStorage["**Custom Storage**<br/>Cloud, Database, etc."]
CustomLock["**Custom Locking**<br/>Distributed Locking"]
end
end
%% Sample apps embed WOPI client
SampleApps --> OOS
%% WOPI client depends on WopiHost backend
OOS --> WopiHost
%% WopiHost host app uses Core implementation
WopiHost --> Core
%% Core dependencies
Core --> Abstractions
Core --> Discovery
%% Library dependencies
Discovery --> Abstractions
Url --> Discovery
Url --> Abstractions
%% Provider implementations
FileSystem --> Abstractions
MemoryLock --> Abstractions
CustomStorage --> Abstractions
CustomLock --> Abstractions
%% Core uses providers
Core --> FileSystem
Core --> MemoryLock
Core --> CustomStorage
Core --> CustomLock
%% Styling
classDef sampleApp fill:#e1f5fe,stroke:#01579b,stroke-width:2px
classDef wopiClient fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef hostApp fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
classDef coreModule fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
classDef libraryModule fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
classDef providerModule fill:#fce4ec,stroke:#880e4f,stroke-width:2px
class SampleApps sampleApp
class OOS wopiClient
class WopiHost hostApp
class Core coreModule
class Abstractions,Discovery,Url libraryModule
class FileSystem,MemoryLock,CustomStorage,CustomLock providerModule
How It Works
-
Sample Applications: The
/samplefolder contains complete applications that embed the WOPI client:- WopiHost.Web: A web application with file management UI that embeds Office Online Server
- WopiHost.Validator: A testing tool for WOPI protocol validation
- WopiHost Sample: A basic WOPI host implementation
-
WOPI Client Integration: The sample applications embed Office Online Server or Microsoft 365 for the Web as a WOPI client component.
-
WopiHost Backend API: The WOPI client depends on the WopiHost backend API (NuGet packages) to serve files:
- WopiHost.Core: Implements the WOPI REST API endpoints, handles authentication, authorization, and orchestrates all operations
- WopiHost.Abstractions: Defines the core interfaces for storage, security, and locking functionality
- WopiHost.Discovery: Queries the WOPI client to understand its capabilities
- WopiHost.Url: Generates proper WOPI URLs based on discovered capabilities
-
Storage & Lock Providers: The WOPI client uses these providers to access and manage files:
- WopiHost.FileSystemProvider: File system storage implementation
- WopiHost.MemoryLockProvider: In-memory locking implementation
- Custom Providers: You can implement your own storage and locking providers
-
Your Own Applications: You can create your own applications by embedding the WOPI client and referencing the WopiHost NuGet packages.
This modular design allows you to:
- Use the sample applications as starting points for your own WOPI-enabled applications
- Embed the WOPI client in your own applications
- Reference individual WopiHost packages to customize the backend API
- Implement custom providers for your specific storage or infrastructure needs
- Test easily with the included validator and sample implementations
Key Differentiators
- Modular Architecture: Complete separation of concerns with 6 dedicated NuGet packages (Abstractions, Core, Discovery, Url, FileSystemProvider, MemoryLockProvider) allowing selective integration
- WOPI Discovery Integration: Dynamic capability detection that queries Office Online Server to determine supported file types and actions, with intelligent URL template resolution and caching
- Advanced Cobalt Support: Optional MS-FSSHTTP protocol integration for enhanced performance and compatibility with Office Web Apps 2013+ features
- Flexible Storage Abstraction: Complete decoupling from file system with clean interfaces supporting any storage backend (cloud, database, custom APIs) through
IWopiStorageProvider - .NET Aspire Integration: Modern cloud-native development experience with service orchestration, OpenTelemetry observability, and containerization support
- Comprehensive WOPI Compliance: Full implementation of the current WOPI specification including file operations, container operations (basic), and ecosystem support (basic)
- Enterprise-Ready Security: Built-in WOPI proof validation, origin checking, and extensible authentication/authorization with JWT token support
- Production-Ready Features: Health checks, in-memory caching, and sample applications for testing and validation
Usage
Prerequisites
- .NET 8 SDK, .NET 9 SDK, or .NET 10 SDK
- Recommended: VS Code or Visual Studio 2022
Building the app
The WopiHost app targets net8.0, net9.0, and net10.0.
If you need a version that targets an older version of .NET, check out the releases:
If you get errors saying that Microsoft.CobaltCore.*.nupkg can't be found, then just remove the reference or see the chapter
