Porting ASP.NET Classic to Unix
Currently, if you are a user of ASP.NET Classic (the WebForms stack) and want to run your code on Unix your only choice is to use Mono’s implementation, with the Mono runtime, and the Mono front-end servers [1].   

There are a couple of downsides to this approach, let me list those:

  • Mono’s ASP.NET stack has not changed much since about 2011
  • It is not actively maintained.
  • Even by 2011 standards, the stack had not kept up with innovation in ASP.NET and in particular lacks asynchronous page support.
  • You would not benefit from any of the high-performance work that is going into .NET Core

We still have users of ASP.NET on Mono which would love for nothing more than to get an upgrade, without having to rewrite their existing code to run on top of the new ASP.NET Core stack.

Recently I was talking with a user that wanted to get his code running under .NET Core, with ASP.NET Classic, and ideally, with the upgraded stack.

This document discusses a possible path to get there.

Bringing ASP.NET Classic to Unix

Microsoft open sourced ASP.NET classic as part of the ReferenceSource and it could be ported to run on Unix again.

There are a couple of pieces of this puzzle:

  • You want to port System.Web from ReferenceSource to run on Unix.
  • This code should run with the .NET Core API
  • Bonus points - you would want to run this hosted inside Kestrel, the new ASP.NET Core embedded server.

I would divide and conquer this process.

Porting ReferenceSource’s System.Web to Unix

I would start by trying to compile and run Microsoft’s full System.Web assembly on top of Mono and reuse the existing hosting infrastructure and servers that are available.   That assembly currently has a few windows-isms embedded into them which is the part that requires the porting. 

You could graft parts of System.Web from Reference Source with the Mono components until you are up and running.

Another option would be to take Mono’s System.Web stack and gradually replace every class in with the ReferenceSource code.

At the end of this exercise, you would end up with the latest edition of ASP.NET WebForms as it is available on .NET 4.7 running on Unix with Mono.

My estimate from looking at this code a couple of years ago is that this could be done in about a month by a couple of seasoned developers.

Porting System.Web to .NET Core

Here you would need to remove some of the dependencies that System.Web has on the desktop .NET API that is not available on .NET Core.    There is a little bit of AppDomain code, but not too much.   The majority of the AppDomain code handling lives on the front-end server (in Mono’s case this is xsp or mod_mono) so there would not be too much work left here to be done.

Hosting ASP.NET Classic on .NET Core

Once you get the first two tasks out of the way, you will want to host your ASP.NET Core with a maintained server.   You have a few choices here, adapting mod_mono and mono’s fastcgi bridge to work with .NET core, or you could try to host the code on the modern and actively developed Kestrel server (and in turn, plug that into your favorite front-end server)

The good news is that the ASP.NET Classic stack only requires the SimpleWorkerRequest class to be implemented.   What you would need to do for Kestrel is to implement this interface in terms of the existing Kestrel operations, and your resulting application server would run.


[1] Mono front-end servers include mod_mono for hosting your code under Apache,  fast-cgi bridge that can be used with many existing Unix web servers, including ngnix and the self-contained xsp minimal HTTP 1.0 server.