How to Use Mono to Run ASP.NET C# Code in Ubuntu Linux

Mono is an open source implementation of Microsoft’s .NET Framework. It aims to help C# developers create cross-platform .NET applications. Although .NET Core is born for multiple platforms (Windows, Linux, and macOS), it is so far not a substitution of .NET framework. If you have an existing project written in .NET framework and want to run it in Linux, Mono is the most efficient way. In this post, I will share how to run an ASP.NET sample of Dynamic Web TWAIN using Mono in Ubuntu Linux.

About Dynamic Web TWAIN

Installing Mono in Ubuntu

Check the OS version:

$lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:    18.04
Codename:   bionic

Download Mono according to your Ubuntu version.

Install XSP:

sudo apt install mono-xsp4

Deploying Web Document Management App in Linux

More and more developers are using Dynamic Web TWAIN SDK to build web document management apps. Dynamic Web TWAIN is the only cross-platform web document scanning SDK designed for Windows, Linux, and macOS. The sample code is written in ASP.NET. Let’s see how to run it in Linux.

Run ASP.NET sample with Mono

Get the source code from

git clone
cd asp-net-document-management

Extract the latest Resources folder from Dynamic Web TWAIN installer and copy it to the project root directory:

- Resources
- SaveToFile.aspx
- UploadWithHTTP.html

You need a FREE 30-day trial license to make Dynamic Web TWAIN SDK work.

Once you get a valid license, you can set it in Resources/dynamsoft.webtwain.config.js:

Dynamsoft.DWT.ProductKey = 'DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==';

Run the project:

xsp4 --port 9000

Scan documents in a Linux web browser

Install SANE:

sudo apt-get install sane

Visit http://localhost:9000/UploadWithHTTP.html in a web browser. If you don’t have Dynamic Web TWAIN service installed, you need to install the .deb file and then refresh the page:

Linux Dynamic Web TWAIN

Scan documents and upload images to the server-side:

Scan document in Ubuntu Linux

Mono ASP.NET upload in Linux

You can also visit the page in Windows:

Scan and upload document in Windows

Source Code