Why can't ASP.NET be hosted on a linux server? - asp.net

ASP.NET is open source so shouldn't it be able to be hosted on any server just like a web app written in any other open source language such as php not limited to a windows server?

ASP.NET Core, the latest version (still in preview) in fact can be run on Linux.
Previous versions of ASP.NET have a dependency on the .NET Framework which only runs on Windows.

Technically, you can via ASP.NET Mono, and in fact Mono has support up to ASP.NET 4.0 and MVC 3.
The limiting factor really is IIS doesn't run on *nix, so you'll not be able to use the configuration aspects of the projects, but you can run the code via Apache modules or FastCGI.
The ASP.NET framework isn't open source (it has too many dependencies on internal code) but ASP.NET MVC and the new .NET Core, and ASP.NET Core releases are.
But just because something's open source, doesn't mean it "runs everywhere" it just means that you have some rights to look at the code, and typically can do things with that - someone still has to write an engine that can interpret and run your code on another operating system.

Related

Is it possible to host an ASP.NET MVC app without the .NET Core runtime or sdk?

I am struggling to understand how all these frameworks interact and depend on each other: .NET Core, .NET Framework, ASP.NET Core, MVC, etc.
This discussion leads me to believe that my MVC app uses ASP.NET Core and .NET Framework, but not .NET Core. If that's true, can I run the MVC app without the .NET Core runtime? If not, why is this app still dependent on the .NET Core runtime?
What I tried
I created a new project in Visual Studio 2017 as follows:
ASP.NET Core Web Application
MVC
.NET Framework
ASP.NET Core 2.1
I published the app as follows:
dotnet publish --self-contained false (to prevent the runtime from being included)
Deploy new ec2 instance with windows server 2019
Install minimal set of dependencies (IIS, .NET Framework, Rewrite Module)
Deploy the published app to IIS
The app did not work at this point. I got a 500.19 with error code 0x8007000d. I got it working by installing the Hosting Bundle. I manually removed a few things that were installed with the hosting bundle, and found that "Microsoft .NET Core 2.1.28 - Windows Server Hosting" is required. I don't know exactly what that is, but it smells to me like the .NET Core runtime is somehow involved here.
Update
When I install the Hosting Bundle, I see a few important things get installed:
C:\Program Files\dotnet\dotnet.exe
C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All\
C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\
C:\Program Files\dotnet\shared\Microsoft.NETCore.App\
When I uninstall the .NET Core Runtime, I am left with just the following:
C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All\
C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\
The app still works at this point. I assume what remains is the ASP.NET Core Runtime, which is different than the .NET Core Runtime. I am just looking to confirm that this app is only dependent on the ASP.NET Core Runtime and .NET Framework, and not at all dependent on .NET Core.
We have a system that has CPU, memory, disk, network card, IO devices, etc. We need a software to manage these resources for us and let us use this system. That software is the kernel. (say Linux)
Now that we can control the hardware we need abstraction on top of it for daily usage for users. We need shell, windowing system, different kind of services and daemons. We call this whole package the Operating System. (say Ubuntu)
Now that we can happily use our computer, we want to write our own applications for our problems or maybe for other's problems. The OS provides us with a programming language and a library of functions and system calls that we can use to create software, just like the OS itself is using them. (say C and glibc)
Suddenly we realize that our software is not portable to other Operating Systems and it has a lot of complex boilerplate codes. So we create a new programming language and provide a new set of library functions but this time way easier to read and understand. (say C# and .NET 5 SDK)
But we have a problem. Our OS does not understand this new language. So we need a layer between our language and the OS. This piece of software must read our program and somehow translate it for the OS. This program is the Runtime. (say .NET 5 Runtime)
OK, let's review. We create an app with C# and .NET. this results in a program that is in the IL language. OS does not understand IL language, therefore we need the .NET runtime to read our IL app and translate it for the OS. But how do we set this up?
We have two options:
We install the .NET runtime on every system that needs to run our app; this way our app becomes portable but it needs the runtime to work.
We include the runtime code inside our app; this way our app does not need the runtime but it won't be portable anymore and since it carries the runtime it will be larger.
Now to clear a few of your confusions:
What is the difference between .NET Framework and .NET Core?
.NET Framework only runs on Windows and has more libraries to use.
.NET Core is cross-platform and has fewer libraries to use but is very fast. It now goes with the name .NET 5 and those extra Windows-only libraries have been added to it.
What is the difference between .NET SDK and Runtime?
SDK provides you with the tools you need to build an app with (SDK includes the Runtime as well).
Runtime is lighter and just runs your app.
What is the difference between .NET Core Runtime and ASP.NET Core Runtime?
.NET Core runtime (.NET 5 runtime now) can only run your console apps and is lighter.
ASP.NET Core runtime can run your web apps.
There are also runtimes for GUI apps capable of running WinForms and WPF apps (Windows-only).
What is MVC?
Model-View-Controller is a design pattern and it is not related to a specific language or framework.

HttpRuntime.IISVersion equivalent in Asp.Net Core 3?

I'm porting some code to Asp.Net Core 3 and would like a way to tell which version of IIS the system is running under or even if it is running via IIS, say verses Nginx.
An identical replacement for HttpRuntime.IISVersion isn't necessary but it would be nice to get some diagnostic info about what web server the site is running on and what version of the webserver it is.
Is there any way to do this in Asp.Net Core 3?

How to deploy ASP.NET website (version prior to ASP.NET 5) to Linux server?

I am currently in process of identifying a mechanism to deploy ASP.NET websites to Linux server. I know this requires Apache to be installed on Linux, and can be achieved using Mono.
I found a lot many articles but they all are referring to ASP.NET version 5 (i believe, vNext). But couldn't find anything for a version prior to that.
Is it due to "System.Web" assembly that we can't deploy ASP.NET website on anything except IIS? I know, OWIN has replaced that in vNext.
Any help on deployment of previous versions of ASP.NET to Linux will be very appreciated.
The new version of ASP.NET, version 5, and more specifically the .NET Core, runs cross-platform. That's why there is a lot of information about running ASP.NET 5 (or vNext) on Linux with Kestrel, the new cross platform webserver for ASP.NET 5.
However, you can run older ASP.NET projects on Apache using, indeed, Mono. The official documentation can be found here: http://www.mono-project.com/docs/web/aspnet/#aspnet-hosting-with-apache and here: http://www.mono-project.com/docs/web/mod_mono/

System requirements for using ASP.NET

I consider to use ASP.NET for developing a real-time appication that will be shown on a browser (IE, FF, Chrome etc.).
I'm wondering what are the system requirements for the server side where the application will be deployed?
Do I have to use IIS or I'm free to choose any web server I want? If IIS only - does it part of any Windows installation (so users do not have to pay extra charge for that?)
Do I have to install .NET Framework?
anything else?
Thank you!
You don't have to use IIS, you could use Apache, nginx, or xsp, but doing so means you have to use mono which is an open source version of the .NET framework, it's a couple of versions behind the real thing, you can find out more info here: http://www.mono-project.com/ASP.NET
If you choose to use Windows/IIS, then IIS is a feature of Windows that can be installed free of charge. You will need to install the .NET framework in order to host an ASP.NET web application, like IIS, the .NET framework and ASP.NET are features of Windows Server 2008 and above that can be installed/uninstalled whenever you like, for free.

What do I need to install to compile Silverlight 2.0 applications on my build server

What's the minimum that I need to have installed on my Build Server (in addition to the standard .Net 3.5 stuff) to allow it to compile Silverlight 2.0 applications?
I have a Silverlight application that seems to be building correctly, but is not playing nicely with a related Web Application project - see this related question that I asked earlier: Silverlight xap file not being copied to ClientBin on Build Server
AFAIK you need Microsoft Silverlight 2 SDK to install on the build server.
HTH
Your build server should be pretty much an exact replication of your development machine as far as plug-ins, assemblies, run-times, SDK's etc.
You build server will be building your app via MSBuild.
In your particular case I suspect that you need to install the Silverlight Toolkit. This will give you the SL development runtime and the appropriate project build requisites for your XAP files to build and be deployed properly.

Resources