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

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/

Related

.NET Core 5.0 Console with WebAPI

I once build a .NET Core Console App that contained a web host, so I could make controllers without using IIS. Isn't that possible in 5.0?
I need it to run as a service later. It used to be so easy :-)
I can't find any guides to that, but I can find guids addressing version 2.1.
Latest .NET Core project templates (and .NET 5 ones) use Kestrel by default.
You can find the related documentation here.
You can also find here specific documentation about running ASP .NET Core as a service in both Windows and Linux, and in the case of Windows, with and without IIS.

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?

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

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.

Is it possible to run a ASP.NET web project created in VS2015 on VSCode OSX?

Thank you for the help in advance.
I'm used to developing asp.net web projects in visual studio for windows. With the new asp.net open source, I'm trying to develop on my mac. I already set my development environment and run the boilerplate. My question now is, can I import a traditional project developed in vs and in some way adapt to run and continue developing in Vscode and dmx?
Yes... So long as it's based on .Net Core.
.Net Framework 4.5, 4.7 etc is most definitely not cross platform and requires Windows and, more often than not, IIS to run.
So I suppose the real answer is, it depends.

Developing ASP.NET application for a Linux Server [duplicate]

This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
For a developer with a Java background, I am interested in exploring software development using the ASP.NET tools/platform as well.
Java web applications (.jsp and servlets) can run on many server platforms.
Question: Will a .NET web application be able to run in a Linux based server? Considering the scenario of not being able to use a Windows server for hosting a web app.
So I know this is an older question but I think it could stand an updated answer.
Microsoft has officially released asp.net vnext and its open source and deploy-able to both Linux and Mac. Its all still pretty new but does rely on the latest builds of mono and thus currently needs you to compile the mono-framework but in time I suspect that it will be easier to access as various linux distros release updated versions of mono. This is a how to setup guide
This information may be somewhat volatile and with updates is due to change.
Update ASP.NET CORE 11/10/2017
asp.net vnext is now known as asp.net core.
asp.net core is being treated as a high priority in Microsoft due in part to its use with microservice architecture and docker and container technologies
It has become much more compatible with existing .net libraries due to .net standard 2.0.
It performs well when compared to other technology stacks such as go and node.js
It depends what specific .NET technologies you're using. The Mono Project provides an Apache module (mod_mono) for running ASP.NET sites, and from what I gather it works well.
Mono doesn't support all the .NET APIs, though - notably WPF (and possibly WCF too, I can't remember) - but it does provide good support for much else of the framework.
If you're starting from scratch and particularly want to target non-Windows servers, then ensuring your project works with Mono would be a good goal to aim for. However, if you need particular APIs or language features that are not supported by Mono, then you will need to use a Windows server for deployment. It's a design-time/architectural choice that should make up front.
You might want to consider this guide that helps Windows developers port their code to Mono/Linux:
Guide: Porting ASP.NET Applications - Mono
I can speak from experience. Even if your ASP.net website only uses .NET libraries supported by Mono you are going to have a hard time getting it to run if its anything beyond Hello World.
You won't have to re-write much code but you will spend hours/days/weeks dealing with little issues with mod_mono/xsp/apache configuration and file permissions and error handling and all the little things that go into a large website. (Be prepared to spend a lot of time asking questions on serverfault :) )
The problem is that a lot of people don't use Mono for ASP.net websites and so there aren't as many people reporting bugs so a lot of things that are minor bugs go un-fixed for a long time.
Now you can publish ASP.NET 5 app to Docker on Linux with Visual Studio. See the below post from Scott Haselman
http://www.hanselman.com/blog/PublishingAnASPNET5AppToDockerOnLinuxWithVisualStudio.aspx
Since the technologies evolve and this question is top ranked in google, we need to include beyond the mono the new asp.net core, which is a complete rewrite of the asp.net to run for production in Linux and Windows and for development for Linux, Windows and Mac:
You can develop and run your ASP.NET Core apps cross-platform on
Windows, Mac and Linux. ASP.NET Core is open source at GitHub.
Yes we can. get familiar with Mono Project and read this article to get started.
For ASP.NET on Linux, check out Mono.
That said, thousands of sites run on Windows Server without any issues. A poorly-configured server with any OS will be vulnerable; Linux won't save you from a poor admin.
So I guess my "best practice" for deplying an ASP.NET app would be to use Windows Server 2008 (likely Web edition). And hire a good administrator.
You can use Mono to run ASP.NET applications on Apache/Linux, however it has a limited subset of what you can do under Windows. As for "they" saying Windows is more vulnerable to attack - it's not true. IIS has had less security problems over the last couple of years that Apache, but in either case it's all down to the administration of the boxes - both OSes can be easily secured. These days the attack points are not the OS or web server software, but the applications themselves.
dotnet is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.
This may be a great start to support Linux.
Now a days .Net is run in multiple platforms,like linux ,Mac os etc.
but mono is not fully platform independent ,Because to deploy .NET in another OS required
third party software.so it is not like java platform independent.
Mono is running in different platform ,because of JIT is there in different os.
Mono is not fully success in moonlight(silver light in .NET) .Not only Research is going on.
Mono uses XSP2 server or apache . some of the big companies are using this project,Some of the robotic project are also running on mono.
For more details http://www.mono-project.com/Main_Page.
There is the Mono Project from Novell that will allow you to run ASP.Net on Apache.
http://www.mono-project.com/Main_Page
The Mono project is your best option. However, it has a lot of pitfalls (like incomplete API support in some areas), and it's legally gray (people like Richard Stallman have derided the use of Mono because of the possibility of Microsoft coming down on Mono by using its patent rights, but that's another story).
Anyway, Apache supports .NET/Mono through a module, but the last time I checked the version supplied with Debian, it gave Perl language support only; I can't say if it's changed since, perhaps someone else can correct me there.

Resources